Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable blue green deployment #92

Merged
merged 3 commits into from
Oct 4, 2024
Merged

Enable blue green deployment #92

merged 3 commits into from
Oct 4, 2024

Conversation

kunduso
Copy link
Owner

@kunduso kunduso commented Oct 4, 2024

No description provided.

Copy link

github-actions bot commented Oct 4, 2024

💰 Infracost report

Monthly estimate generated

Estimate details (includes details of unsupported resources)
──────────────────────────────────
1 project has no cost estimate change.
Run the following command to see its breakdown: infracost breakdown --path=/path/to/code

──────────────────────────────────
12 cloud resources were detected:
∙ 1 was estimated
∙ 10 were free
∙ 1 is not supported yet, see https://infracost.io/requested-resources:
  ∙ 1 x aws_codedeploy_deployment_group
This comment will be updated when code changes.

Copy link

github-actions bot commented Oct 4, 2024

Terraform Format and Style 🖌success

Terraform Initialization ⚙️success

Terraform Plan 📖success

Terraform Validation 🤖success

Show Plan

terraform
data.aws_caller_identity.current: Reading...
data.aws_ssm_parameter.infra_output: Reading...
data.aws_iam_policy_document.assume_by_codedeploy: Reading...
aws_codedeploy_app.application_main: Refreshing state... [id=b326775b-2c4f-418c-afe6-c643eafbbc4b:app-6]
aws_iam_role.ecs_task_execution_role: Refreshing state... [id=app-6-task-execution-role]
data.aws_iam_policy_document.assume_by_codedeploy: Read complete after 0s [id=4250039221]
aws_iam_role.codedeploy: Refreshing state... [id=app-6-code-deploy-role]
data.aws_caller_identity.current: Read complete after 0s [id=743794601996]
aws_iam_role.ecs_task_role: Refreshing state... [id=app-6-task-role]
data.aws_ssm_parameter.infra_output: Read complete after 1s [id=/app-6/output]
aws_iam_policy.secrets_manager_read_policy: Refreshing state... [id=arn:aws:iam::743794601996:policy/app-6-ecs-fargate-secrets-manager-access]
aws_iam_role_policy_attachment.custom: Refreshing state... [id=app-6-task-execution-role-20241003153209502800000001]
aws_ecs_task_definition.web_app: Refreshing state... [id=app-6]
data.aws_iam_policy_document.codedeploy: Reading...
data.aws_iam_policy_document.codedeploy: Read complete after 0s [id=1211725747]
aws_iam_role_policy.codedeploy: Refreshing state... [id=app-6-code-deploy-role:terraform-20241003165455650800000001]
aws_iam_role_policy_attachment.attach_secrets_read_task_role: Refreshing state... [id=app-6-task-role-20241003153209524100000003]
aws_iam_role_policy_attachment.attach_secrets_read_task_execution_role: Refreshing state... [id=app-6-task-execution-role-20241003153209508300000002]
aws_ecs_service.service: Refreshing state... [id=arn:aws:ecs:us-east-2:743794601996:service/app-6/app-6]
aws_codedeploy_deployment_group.application_main: Refreshing state... [id=664c9ff4-b726-4afb-9654-85030ab22491]
local_file.code_deploy_sh: Refreshing state... [id=cf34f9cfde28f8cd9c1f715b3c2ad8e486da49bb]
terraform_data.code_deploy: Refreshing state... [id=35aa4fa1-300e-5e37-fb6c-468a9b703298]

Note: Objects have changed outside of Terraform

Terraform detected the following changes made outside of Terraform since the
last "terraform apply" which may have affected this plan:

  # local_file.code_deploy_sh has been deleted
  - resource "local_file" "code_deploy_sh" {
      - content              = <<-EOT
            #!/bin/bash
                echo "Starting CodeDeploy agent deployment"
                ID=$(aws deploy create-deployment \
                    --application-name app-6 \
                    --deployment-config-name CodeDeployDefault.OneAtATime \
                    --deployment-group-name app-6-deploy-group \
                    --appspec-content file://appspec.json \
                    --description "Deployment from Terraform" \
                    --output json | jq -r '.deploymentId')
                echo "waiting for deployment to complete"
                STATUS=$(aws deploy get-deployment \
                  --deployment-id $ID \
                  --output json | jq -r '.deploymentInfo.status')
                while [ "$STATUS" == "Created" || "$STATUS" == "InProgress" || "$STATUS" == "Pending" || "$STATUS" == "Queued" || "$STATUS" == "Ready" ||]; do
                    echo "Deployment status: $STATUS"
                    STATUS=$(aws deploy get-deployment \
                        --deployment-id $ID \
                        --output json | jq -r '.deploymentInfo.status')
                    echo "waiting for 30 seconds."
                    sleep 30
                done
                if [ "$STATUS" == "Succeeded" ]; then
                    echo "Deployment $ID succeeded"
                else
                    echo "Deployment $ID failed"
                    exit 1
                fi
        EOT -> null
      - content_base64sha256 = "S0J3zZbytm0rV6wdAargPJ2K921XEpvVKn0u3mlb/AY=" -> null
      - content_base64sha512 = "XB1Lxd3iJKXbiHkSGPD04Ff+8vwTXZe+TWgYReUfoNgGQbBUkzGdGAsbDwu69UlTlSRxcMnW2oviJXmGjlWMlA==" -> null
      - content_md5          = "1744aa717745ac21744f4d26cf832324" -> null
      - content_sha1         = "cf34f9cfde28f8cd9c1f715b3c2ad8e486da49bb" -> null
      - content_sha256       = "4b4277cd96f2b66d2b57ac1d01aae03c9d8af76d57129bd52a7d2ede695bfc06" -> null
      - content_sha512       = "5c1d4bc5dde224a5db88791218f0f4e057fef2fc135d97be4d681845e51fa0d80641b05493319d180b1b0f0bbaf5495395247170c9d6da8be22579868e558c94" -> null
      - directory_permission = "0777" -> null
      - file_permission      = "0777" -> null
      - filename             = "./code_deploy.sh" -> null
      - id                   = "cf34f9cfde28f8cd9c1f715b3c2ad8e486da49bb" -> null
    }


Unless you have made equivalent changes to your configuration, or ignored the
relevant attributes using ignore_changes, the following plan may include
actions to undo or respond to these changes.

─────────────────────────────────────────────────────────────────────────────

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # aws_ecs_task_definition.web_app must be replaced
-/+ resource "aws_ecs_task_definition" "web_app" {
      ~ arn                      = "arn:aws:ecs:us-east-2:743794601996:task-definition/app-6:33" -> (known after apply)
      ~ arn_without_revision     = "arn:aws:ecs:us-east-2:743794601996:task-definition/app-6" -> (known after apply)
      ~ container_definitions    = (sensitive value) # forces replacement
      ~ id                       = "app-6" -> (known after apply)
      ~ revision                 = 33 -> (known after apply)
      - tags                     = {} -> null
        # (12 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }

  # local_file.code_deploy_sh will be created
  + resource "local_file" "code_deploy_sh" {
      + content              = <<-EOT
            #!/bin/bash
            echo "Starting CodeDeploy agent deployment"
            ID=$(aws deploy create-deployment \
                --application-name app-6 \
                --deployment-config-name CodeDeployDefault.OneAtATime \
                --deployment-group-name app-6-deploy-group \
                --appspec-content "$(cat appspec.json)" \
                --description "Deployment from Terraform" \
                --output json | jq -r '.deploymentId')
            
            echo "waiting for deployment to complete"
            STATUS=$(aws deploy get-deployment \
              --deployment-id "$ID" \
              --output json | jq -r '.deploymentInfo.status')
            
            while [ "$STATUS" == "Created" ] || [ "$STATUS" == "InProgress" ] || [ "$STATUS" == "Pending" ] || [ "$STATUS" == "Queued" ] || [ "$STATUS" == "Ready" ]; do
                echo "Deployment status: $STATUS"
                STATUS=$(aws deploy get-deployment \
                    --deployment-id "$ID" \
                    --output json | jq -r '.deploymentInfo.status')
                echo "waiting for 30 seconds."
                sleep 30
            done
            
            if [ "$STATUS" == "Succeeded" ]; then
                echo "Deployment $ID succeeded"
            else
                echo "Deployment $ID failed"
                exit 1
            fi
        EOT
      + content_base64sha256 = (known after apply)
      + content_base64sha512 = (known after apply)
      + content_md5          = (known after apply)
      + content_sha1         = (known after apply)
      + content_sha256       = (known after apply)
      + content_sha512       = (known after apply)
      + directory_permission = "0777"
      + file_permission      = "0777"
      + filename             = "./code_deploy.sh"
      + id                   = (known after apply)
    }

  # terraform_data.code_deploy is tainted, so must be replaced
-/+ resource "terraform_data" "code_deploy" {
      ~ id               = "35aa4fa1-300e-5e37-fb6c-468a9b703298" -> (known after apply)
      ~ input            = "2de040e3bb56917abee6049aed3ecb10a0d50a4425490b17a3cd1039d06c0064" -> (known after apply)
      ~ output           = "2de040e3bb56917abee6049aed3ecb10a0d50a4425490b17a3cd1039d06c0064" -> (known after apply)
      ~ triggers_replace = {
          ~ content              = <<-EOT
                #!/bin/bash
              -     echo "Starting CodeDeploy agent deployment"
              -     ID=$(aws deploy create-deployment \
              -         --application-name app-6 \
              -         --deployment-config-name CodeDeployDefault.OneAtATime \
              -         --deployment-group-name app-6-deploy-group \
              -         --appspec-content file://appspec.json \
              -         --description "Deployment from Terraform" \
              -         --output json | jq -r '.deploymentId')
              -     echo "waiting for deployment to complete"
              + echo "Starting CodeDeploy agent deployment"
              + ID=$(aws deploy create-deployment \
              +     --application-name app-6 \
              +     --deployment-config-name CodeDeployDefault.OneAtATime \
              +     --deployment-group-name app-6-deploy-group \
              +     --appspec-content "$(cat appspec.json)" \
              +     --description "Deployment from Terraform" \
              +     --output json | jq -r '.deploymentId')
              + 
              + echo "waiting for deployment to complete"
              + STATUS=$(aws deploy get-deployment \
              +   --deployment-id "$ID" \
              +   --output json | jq -r '.deploymentInfo.status')
              + 
              + while [ "$STATUS" == "Created" ] || [ "$STATUS" == "InProgress" ] || [ "$STATUS" == "Pending" ] || [ "$STATUS" == "Queued" ] || [ "$STATUS" == "Ready" ]; do
              +     echo "Deployment status: $STATUS"
                    STATUS=$(aws deploy get-deployment \
              -       --deployment-id $ID \
              -       --output json | jq -r '.deploymentInfo.status')
              -     while [ "$STATUS" == "Created" || "$STATUS" == "InProgress" || "$STATUS" == "Pending" || "$STATUS" == "Queued" || "$STATUS" == "Ready" ||]; do
              -         echo "Deployment status: $STATUS"
              -         STATUS=$(aws deploy get-deployment \
              -             --deployment-id $ID \
              -             --output json | jq -r '.deploymentInfo.status')
              -         echo "waiting for 30 seconds."
              -         sleep 30
              -     done
              -     if [ "$STATUS" == "Succeeded" ]; then
              -         echo "Deployment $ID succeeded"
              -     else
              -         echo "Deployment $ID failed"
              -         exit 1
              -     fi
              +         --deployment-id "$ID" \
              +         --output json | jq -r '.deploymentInfo.status')
              +     echo "waiting for 30 seconds."
              +     sleep 30
              + done
              + 
              + if [ "$STATUS" == "Succeeded" ]; then
              +     echo "Deployment $ID succeeded"
              + else
              +     echo "Deployment $ID failed"
              +     exit 1
              + fi
            EOT
          ~ content_base64sha256 = "S0J3zZbytm0rV6wdAargPJ2K921XEpvVKn0u3mlb/AY=" -> (known after apply)
          ~ content_base64sha512 = "XB1Lxd3iJKXbiHkSGPD04Ff+8vwTXZe+TWgYReUfoNgGQbBUkzGdGAsbDwu69UlTlSRxcMnW2oviJXmGjlWMlA==" -> (known after apply)
          ~ content_md5          = "1744aa717745ac21744f4d26cf832324" -> (known after apply)
          ~ content_sha1         = "cf34f9cfde28f8cd9c1f715b3c2ad8e486da49bb" -> (known after apply)
          ~ content_sha256       = "4b4277cd96f2b66d2b57ac1d01aae03c9d8af76d57129bd52a7d2ede695bfc06" -> (known after apply)
          ~ content_sha512       = "5c1d4bc5dde224a5db88791218f0f4e057fef2fc135d97be4d681845e51fa0d80641b05493319d180b1b0f0bbaf5495395247170c9d6da8be22579868e558c94" -> (known after apply)
          ~ id                   = "cf34f9cfde28f8cd9c1f715b3c2ad8e486da49bb" -> (known after apply)
            # (6 unchanged attributes hidden)
        }
    }

Plan: 3 to add, 0 to change, 2 to destroy.

─────────────────────────────────────────────────────────────────────────────

Saved the plan to: TFplan.JSON

To perform exactly these actions, run the following command to apply:
    terraform apply "TFplan.JSON"

Pushed by: @kunduso, Action: pull_request

@kunduso kunduso merged commit 30d811b into main Oct 4, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant