Container Pipeline Exercise

The AWS Resources for pipeline, etc are build using Terraform.

  1. Create the Terraform state bucket
  2. Initialize Terraform
  3. Plan Terraform
  4. Apply terraform

First Create the state file s3 bucket

aws s3 mb s3://$NAME_S3_BUCKET --region us-west-2

make_bucket: $NAME_S3_BUCKET

Ensure the s3 bucket is updates and is unique.

Inside our Terraform Directory in the devsecops repo cd ~/environments/devsecopspipeline/

Update the ~/environments/devsecopspipeline/terraform/config.tf with the bucket name to store terraform state

terraform {
    backend "s3" {
        bucket = "$NAME_S3_BUCKET"
        key    = "$NAME_S3_BUCKET/terraform_state"
        region = "us-west-2"
    }
}

Initialize the Terraform

cd ~/environment/devsecopspipeline/

Use make to Initialize, this is the first step of the Terraform execution.

make tf_clean tf_init

Expand me...

Terraform Plan

Terraform Plan will create the plan for the run and allow us to see all the resources that will be created.

make tf_plan

Expand here is what it looks like in its entirety

Terraform Apply

Terraform uses the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: + create

make tf_apply

Expand here is what it looks like in its entirety

Navigate to AWS codepipeline and ensure your Pipeline created properly

https://us-west-2.console.aws.amazon.com/codesuite/codepipeline/pipeline

Don’t worry about the failure, were going to fix that in the next Exercise