From ddb8c1b8079d844c395b1be4a55102d4a6260d08 Mon Sep 17 00:00:00 2001 From: Brian Vu Date: Fri, 24 Jun 2022 16:25:36 -0700 Subject: [PATCH 1/2] fix: added maxsplit=1 to python script --- .circleci/test-deploy.yml | 381 ++++++++++++++------------- src/jobs/deploy-service-update.yml | 2 + src/scripts/get-prev-task.sh | 10 +- src/scripts/update_container_defs.py | 2 +- 4 files changed, 203 insertions(+), 192 deletions(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 3bd6c015..41c9f5c1 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -368,81 +368,81 @@ workflows: ################# # Fargate ################# - - build-test-app: - name: fargate_build-test-app - docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com" - docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}:${CIRCLE_SHA1}" - context: [CPE_ORBS_AWS] - filters: *filters - - set-up-test-env: - name: fargate_set-up-test-env - filters: *filters - requires: - - fargate_build-test-app - aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_FARGATE} - terraform-config-dir: "tests/terraform_setup/fargate" - context: [CPE_ORBS_AWS] - - test-service-update: - name: fargate_test-update-service-command - filters: *filters - requires: - - fargate_set-up-test-env - aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_FARGATE} - family-name: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-service" - service-name: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-service" - docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com" - docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}:${CIRCLE_SHA1}" - context: [CPE_ORBS_AWS] - - aws-ecs/deploy-service-update: - name: fargate_test-update-service-job - docker-image-for-job: cimg/python:3.10.4 - filters: *filters - requires: - - fargate_test-update-service-command - aws-access-key-id: AWS_ACCESS_KEY_ID - aws-region: AWS_DEFAULT_REGION - profile-name: "ECS_TEST_PROFILE" - family: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-service" - cluster: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-cluster" - container-env-var-updates: 'container=${AWS_RESOURCE_NAME_PREFIX_FARGATE}-service,name=VERSION_INFO,value="${CIRCLE_SHA1}_${CIRCLE_BUILD_NUM}",container=${AWS_RESOURCE_NAME_PREFIX_FARGATE}-service,name=BUILD_DATE,value=$(date)' - # test the force-new-deployment flag - force-new-deployment: true - verify-revision-is-deployed: true - max-poll-attempts: 40 - poll-interval: 10 - context: [CPE_ORBS_AWS] - post-steps: - - test-deployment: - service-name: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-service" - cluster: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-cluster" - - aws-ecs/deploy-service-update: - name: fargate_test-update-service-skip-registration - docker-image-for-job: cimg/python:3.10.4 - filters: *filters - requires: - - fargate_test-update-service-job - aws-access-key-id: AWS_ACCESS_KEY_ID - aws-region: AWS_DEFAULT_REGION - profile-name: "ECS_TEST_PROFILE" - family: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-service" - cluster: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-cluster" - # test skipping registration of a new task definition - skip-task-definition-registration: true - # test the enable-circuit-breaker flag - enable-circuit-breaker: true - verify-revision-is-deployed: true - max-poll-attempts: 40 - poll-interval: 10 - context: [CPE_ORBS_AWS] - - tear-down-test-env: - name: fargate_tear-down-test-env - filters: *filters - requires: - - fargate_test-update-service-skip-registration - - test-fargatespot - aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_FARGATE} - terraform-config-dir: "tests/terraform_setup/fargate" - context: [CPE_ORBS_AWS] + # - build-test-app: + # name: fargate_build-test-app + # docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com" + # docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}:${CIRCLE_SHA1}" + # context: [CPE_ORBS_AWS] + # filters: *filters + # - set-up-test-env: + # name: fargate_set-up-test-env + # filters: *filters + # requires: + # - fargate_build-test-app + # aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_FARGATE} + # terraform-config-dir: "tests/terraform_setup/fargate" + # context: [CPE_ORBS_AWS] + # - test-service-update: + # name: fargate_test-update-service-command + # filters: *filters + # requires: + # - fargate_set-up-test-env + # aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_FARGATE} + # family-name: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-service" + # service-name: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-service" + # docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com" + # docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}:${CIRCLE_SHA1}" + # context: [CPE_ORBS_AWS] + # - aws-ecs/deploy-service-update: + # name: fargate_test-update-service-job + # docker-image-for-job: cimg/python:3.10.4 + # filters: *filters + # requires: + # - fargate_test-update-service-command + # aws-access-key-id: AWS_ACCESS_KEY_ID + # aws-region: AWS_DEFAULT_REGION + # profile-name: "ECS_TEST_PROFILE" + # family: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-service" + # cluster: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-cluster" + # container-env-var-updates: 'container=${AWS_RESOURCE_NAME_PREFIX_FARGATE}-service,name=VERSION_INFO,value="${CIRCLE_SHA1}_${CIRCLE_BUILD_NUM}",container=${AWS_RESOURCE_NAME_PREFIX_FARGATE}-service,name=BUILD_DATE,value=$(date)' + # # test the force-new-deployment flag + # force-new-deployment: true + # verify-revision-is-deployed: true + # max-poll-attempts: 40 + # poll-interval: 10 + # context: [CPE_ORBS_AWS] + # post-steps: + # - test-deployment: + # service-name: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-service" + # cluster: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-cluster" + # - aws-ecs/deploy-service-update: + # name: fargate_test-update-service-skip-registration + # docker-image-for-job: cimg/python:3.10.4 + # filters: *filters + # requires: + # - fargate_test-update-service-job + # aws-access-key-id: AWS_ACCESS_KEY_ID + # aws-region: AWS_DEFAULT_REGION + # profile-name: "ECS_TEST_PROFILE" + # family: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-service" + # cluster: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-cluster" + # # test skipping registration of a new task definition + # skip-task-definition-registration: true + # # test the enable-circuit-breaker flag + # enable-circuit-breaker: true + # verify-revision-is-deployed: true + # max-poll-attempts: 40 + # poll-interval: 10 + # context: [CPE_ORBS_AWS] + # - tear-down-test-env: + # name: fargate_tear-down-test-env + # filters: *filters + # requires: + # - fargate_test-update-service-skip-registration + # - test-fargatespot + # aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_FARGATE} + # terraform-config-dir: "tests/terraform_setup/fargate" + # context: [CPE_ORBS_AWS] ################# # EC2 @@ -519,7 +519,8 @@ workflows: family: "${AWS_RESOURCE_NAME_PREFIX_EC2}-family" service-name: "${AWS_RESOURCE_NAME_PREFIX_EC2}-service" cluster: "${AWS_RESOURCE_NAME_PREFIX_EC2}-cluster" - container-env-var-updates: 'container=${AWS_RESOURCE_NAME_PREFIX_EC2}-service,name=VERSION_INFO,value="Asterisk * expansion test ${CIRCLE_SHA1}_${CIRCLE_BUILD_NUM}",container=${AWS_RESOURCE_NAME_PREFIX_EC2}-service,name=BUILD_DATE,value=$(date)' + #container-env-var-updates: 'container=${AWS_RESOURCE_NAME_PREFIX_EC2}-service,name=VERSION_INFO,value="Asterisk * expansion test ${CIRCLE_SHA1}_${CIRCLE_BUILD_NUM}",container=${AWS_RESOURCE_NAME_PREFIX_EC2}-service,name=BUILD_DATE,value=$(date)' + container-env-var-updates: 'container=${AWS_RESOURCE_NAME_PREFIX_EC2}-service,name=VERSION_INFO,value="Asterisk * expansion test ${CIRCLE_SHA1}_${CIRCLE_BUILD_NUM}",container=${AWS_RESOURCE_NAME_PREFIX_EC2}-service,name=BUILD_DATE,value="YmV0dHkgaXMgaG90Cgo="' verify-revision-is-deployed: true fail-on-verification-timeout: false post-steps: @@ -542,124 +543,124 @@ workflows: # # FargateSpot # ################# - - test-fargatespot: - context: [CPE_ORBS_AWS] - filters: *filters - requires: - - fargate_set-up-test-env + # - test-fargatespot: + # context: [CPE_ORBS_AWS] + # filters: *filters + # requires: + # - fargate_set-up-test-env ################# # CodeDeploy ################# - - build-test-app: - name: codedeploy_fargate_build-test-app - docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com" - docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}:${CIRCLE_SHA1}" - context: [CPE_ORBS_AWS] - filters: *filters - - set-up-test-env: - name: codedeploy_fargate_set-up-test-env - filters: *filters - requires: - - codedeploy_fargate_build-test-app - terraform-image: "hashicorp/terraform:1.1.9" - aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE} - terraform-config-dir: "tests/terraform_setup/fargate_codedeploy" - context: [CPE_ORBS_AWS] - - test-service-update: - name: codedeploy_fargate_test-update-service-command - filters: *filters - requires: - - codedeploy_fargate_set-up-test-env - aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE} - family-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" - service-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" - docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com" - docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}:${CIRCLE_SHA1}" - skip-service-update: true - context: [CPE_ORBS_AWS] - - aws-ecs/deploy-service-update: - name: codedeploy_fargate_test-update-service-job - docker-image-for-job: cimg/python:3.10.4 - filters: *filters - requires: - - codedeploy_fargate_test-update-service-command - aws-access-key-id: AWS_ACCESS_KEY_ID - aws-region: AWS_DEFAULT_REGION - family: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" - cluster: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-cluster" - container-image-name-updates: "container=${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service,image-and-tag=${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}:${CIRCLE_SHA1}" - container-env-var-updates: 'container=${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service,name=VERSION_INFO,value="${CIRCLE_SHA1}_${CIRCLE_BUILD_NUM}",container=${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service,name=BUILD_DATE,value=$(date)' - deployment-controller: "CODE_DEPLOY" - codedeploy-application-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-codedeployapp" - codedeploy-deployment-group-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-codedeploygroup" - codedeploy-load-balanced-container-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" - codedeploy-load-balanced-container-port: 8080 - verify-revision-is-deployed: false - context: [CPE_ORBS_AWS] - post-steps: - - wait-for-codedeploy-deployment: - application-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-codedeployapp" - deployment-group-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-codedeploygroup" - - test-deployment: - service-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" - cluster: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-cluster" - delete-load-balancer: false - - aws-ecs/deploy-service-update: - name: codedeploy_fargate_test-update-and-wait-service-job - docker-image-for-job: cimg/python:3.10.4 - context: [CPE_ORBS_AWS] - filters: *filters - requires: - - codedeploy_fargate_test-update-service-job - aws-access-key-id: AWS_ACCESS_KEY_ID - aws-region: AWS_DEFAULT_REGION - family: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" - cluster: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-cluster" - container-image-name-updates: "container=${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service,image-and-tag=${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}:${CIRCLE_SHA1}" - container-env-var-updates: 'container=${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service,name=VERSION_INFO,value="${CIRCLE_SHA1}_${CIRCLE_BUILD_NUM}",container=${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service,name=BUILD_DATE,value=$(date)' - deployment-controller: "CODE_DEPLOY" - codedeploy-application-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-codedeployapp" - codedeploy-deployment-group-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-codedeploygroup" - codedeploy-load-balanced-container-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" - codedeploy-load-balanced-container-port: 8080 - verify-revision-is-deployed: true - verification-timeout: "12m" - post-steps: - - test-deployment: - service-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" - cluster: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-cluster" - delete-load-balancer: true - - delete-service: - service-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" - cluster: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-cluster" - - tear-down-test-env: - name: codedeploy_fargate_tear-down-test-env - requires: - - codedeploy_fargate_test-update-and-wait-service-job - terraform-image: "hashicorp/terraform:1.1.9" - aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE} - terraform-config-dir: "tests/terraform_setup/fargate_codedeploy" - context: [CPE_ORBS_AWS] - filters: *filters - - orb-tools/pack: - filters: *filters - - orb-tools/publish: - orb-name: circleci/aws-ecs - vcs-type: << pipeline.project.type >> - pub-type: production - requires: - - orb-tools/pack - - ec2_tear-down-test-env - - fargate_tear-down-test-env - - codedeploy_fargate_tear-down-test-env - - integration-test-ecs-cli-install - context: orb-publisher - filters: - branches: - ignore: /.*/ - tags: - only: /^v[0-9]+\.[0-9]+\.[0-9]+$/ + # - build-test-app: + # name: codedeploy_fargate_build-test-app + # docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com" + # docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}:${CIRCLE_SHA1}" + # context: [CPE_ORBS_AWS] + # filters: *filters + # - set-up-test-env: + # name: codedeploy_fargate_set-up-test-env + # filters: *filters + # requires: + # - codedeploy_fargate_build-test-app + # terraform-image: "hashicorp/terraform:1.1.9" + # aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE} + # terraform-config-dir: "tests/terraform_setup/fargate_codedeploy" + # context: [CPE_ORBS_AWS] + # - test-service-update: + # name: codedeploy_fargate_test-update-service-command + # filters: *filters + # requires: + # - codedeploy_fargate_set-up-test-env + # aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE} + # family-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" + # service-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" + # docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com" + # docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}:${CIRCLE_SHA1}" + # skip-service-update: true + # context: [CPE_ORBS_AWS] + # - aws-ecs/deploy-service-update: + # name: codedeploy_fargate_test-update-service-job + # docker-image-for-job: cimg/python:3.10.4 + # filters: *filters + # requires: + # - codedeploy_fargate_test-update-service-command + # aws-access-key-id: AWS_ACCESS_KEY_ID + # aws-region: AWS_DEFAULT_REGION + # family: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" + # cluster: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-cluster" + # container-image-name-updates: "container=${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service,image-and-tag=${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}:${CIRCLE_SHA1}" + # container-env-var-updates: 'container=${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service,name=VERSION_INFO,value="${CIRCLE_SHA1}_${CIRCLE_BUILD_NUM}",container=${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service,name=BUILD_DATE,value=$(date)' + # deployment-controller: "CODE_DEPLOY" + # codedeploy-application-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-codedeployapp" + # codedeploy-deployment-group-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-codedeploygroup" + # codedeploy-load-balanced-container-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" + # codedeploy-load-balanced-container-port: 8080 + # verify-revision-is-deployed: false + # context: [CPE_ORBS_AWS] + # post-steps: + # - wait-for-codedeploy-deployment: + # application-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-codedeployapp" + # deployment-group-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-codedeploygroup" + # - test-deployment: + # service-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" + # cluster: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-cluster" + # delete-load-balancer: false + # - aws-ecs/deploy-service-update: + # name: codedeploy_fargate_test-update-and-wait-service-job + # docker-image-for-job: cimg/python:3.10.4 + # context: [CPE_ORBS_AWS] + # filters: *filters + # requires: + # - codedeploy_fargate_test-update-service-job + # aws-access-key-id: AWS_ACCESS_KEY_ID + # aws-region: AWS_DEFAULT_REGION + # family: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" + # cluster: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-cluster" + # container-image-name-updates: "container=${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service,image-and-tag=${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}:${CIRCLE_SHA1}" + # container-env-var-updates: 'container=${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service,name=VERSION_INFO,value="${CIRCLE_SHA1}_${CIRCLE_BUILD_NUM}",container=${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service,name=BUILD_DATE,value=$(date)' + # deployment-controller: "CODE_DEPLOY" + # codedeploy-application-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-codedeployapp" + # codedeploy-deployment-group-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-codedeploygroup" + # codedeploy-load-balanced-container-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" + # codedeploy-load-balanced-container-port: 8080 + # verify-revision-is-deployed: true + # verification-timeout: "12m" + # post-steps: + # - test-deployment: + # service-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" + # cluster: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-cluster" + # delete-load-balancer: true + # - delete-service: + # service-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" + # cluster: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-cluster" + # - tear-down-test-env: + # name: codedeploy_fargate_tear-down-test-env + # requires: + # - codedeploy_fargate_test-update-and-wait-service-job + # terraform-image: "hashicorp/terraform:1.1.9" + # aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE} + # terraform-config-dir: "tests/terraform_setup/fargate_codedeploy" + # context: [CPE_ORBS_AWS] + # filters: *filters + # - orb-tools/pack: + # filters: *filters + # - orb-tools/publish: + # orb-name: circleci/aws-ecs + # vcs-type: << pipeline.project.type >> + # pub-type: production + # requires: + # - orb-tools/pack + # - ec2_tear-down-test-env + # - fargate_tear-down-test-env + # - codedeploy_fargate_tear-down-test-env + # - integration-test-ecs-cli-install + # context: orb-publisher + # filters: + # branches: + # ignore: /.*/ + # tags: + # only: /^v[0-9]+\.[0-9]+\.[0-9]+$/ commands: wait-for-codedeploy-deployment: description: "Wait for the CodeDeploy deployment to be successful" diff --git a/src/jobs/deploy-service-update.yml b/src/jobs/deploy-service-update.yml index 49ea4063..2382b926 100644 --- a/src/jobs/deploy-service-update.yml +++ b/src/jobs/deploy-service-update.yml @@ -212,3 +212,5 @@ steps: task-definition-tags: << parameters.task-definition-tags >> verification-timeout: << parameters.verification-timeout >> profile-name: << parameters.profile-name >> + - store_artifacts: + path: test.txt diff --git a/src/scripts/get-prev-task.sh b/src/scripts/get-prev-task.sh index f9b34772..4540b015 100644 --- a/src/scripts/get-prev-task.sh +++ b/src/scripts/get-prev-task.sh @@ -30,11 +30,18 @@ cat <<< "$ECS_SCRIPT_UPDATE_CONTAINER_DEFS" > "$UPDATE_CONTAINER_DEFS_SCRIPT_FIL # Prepare container definitions CONTAINER_DEFS=$(python "$UPDATE_CONTAINER_DEFS_SCRIPT_FILE" "$PREVIOUS_TASK_DEFINITION" "$ECS_PARAM_CONTAINER_IMAGE_NAME_UPDATES" "$ECS_PARAM_CONTAINER_ENV_VAR_UPDATES") - +{ + echo "PTD: ${PREVIOUS_TASK_DEFINITION}" + echo "CINU: ${ECS_PARAM_CONTAINER_IMAGE_NAME_UPDATES}" + echo "CEVU: ${ECS_PARAM_CONTAINER_ENV_VAR_UPDATES}" +} >> test.txt # Escape single quotes from environment variables for BASH_ENV CLEANED_CONTAINER_DEFS=$(echo "$CONTAINER_DEFS" | sed -E "s:':'\\\'':g") +{ + echo "CCD: ${CLEANED_CONTAINER_DEFS}" +} >> test.txt # Prepare script for getting task definition values @@ -101,6 +108,7 @@ echo "export CCI_ORB_AWS_ECS_TAGS='${TAGS}'" >> "$BASH_ENV" echo "export CCI_ORB_AWS_ECS_PROXY_CONFIGURATION='${PROXY_CONFIGURATION}'" >> "$BASH_ENV" +echo "RP: ${RUNTIME_PLATFORM}" >> test.txt echo "export CCI_ORB_AWS_ECS_RUNTIME_PLATFORM='${RUNTIME_PLATFORM}'" >> "$BASH_ENV" rm "$UPDATE_CONTAINER_DEFS_SCRIPT_FILE" "$GET_TASK_DFN_VAL_SCRIPT_FILE" diff --git a/src/scripts/update_container_defs.py b/src/scripts/update_container_defs.py index 683e3855..a4db9566 100644 --- a/src/scripts/update_container_defs.py +++ b/src/scripts/update_container_defs.py @@ -34,7 +34,7 @@ def run(previous_task_definition, container_image_name_updates, container_name = kv[1].strip() env_var_name_kv = env_kv_pairs[index+1].split('=') env_var_name = env_var_name_kv[1].strip() - env_var_value_kv = env_kv_pairs[index+2].split('=') + env_var_value_kv = env_kv_pairs[index+2].split('=', maxsplit=1) env_var_value = env_var_value_kv[1].strip() if env_var_name_kv[0].strip() != 'name' or env_var_value_kv[0].strip() != 'value': raise ValueError( From 5398335bc393e03ca0866a8e531c938af1535f9f Mon Sep 17 00:00:00 2001 From: Brian Vu Date: Sun, 26 Jun 2022 00:02:25 -0700 Subject: [PATCH 2/2] chore: code cleanup --- .circleci/test-deploy.yml | 381 ++++++++++++++--------------- src/jobs/deploy-service-update.yml | 2 - src/scripts/get-prev-task.sh | 10 - 3 files changed, 190 insertions(+), 203 deletions(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 41c9f5c1..3bd6c015 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -368,81 +368,81 @@ workflows: ################# # Fargate ################# - # - build-test-app: - # name: fargate_build-test-app - # docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com" - # docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}:${CIRCLE_SHA1}" - # context: [CPE_ORBS_AWS] - # filters: *filters - # - set-up-test-env: - # name: fargate_set-up-test-env - # filters: *filters - # requires: - # - fargate_build-test-app - # aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_FARGATE} - # terraform-config-dir: "tests/terraform_setup/fargate" - # context: [CPE_ORBS_AWS] - # - test-service-update: - # name: fargate_test-update-service-command - # filters: *filters - # requires: - # - fargate_set-up-test-env - # aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_FARGATE} - # family-name: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-service" - # service-name: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-service" - # docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com" - # docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}:${CIRCLE_SHA1}" - # context: [CPE_ORBS_AWS] - # - aws-ecs/deploy-service-update: - # name: fargate_test-update-service-job - # docker-image-for-job: cimg/python:3.10.4 - # filters: *filters - # requires: - # - fargate_test-update-service-command - # aws-access-key-id: AWS_ACCESS_KEY_ID - # aws-region: AWS_DEFAULT_REGION - # profile-name: "ECS_TEST_PROFILE" - # family: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-service" - # cluster: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-cluster" - # container-env-var-updates: 'container=${AWS_RESOURCE_NAME_PREFIX_FARGATE}-service,name=VERSION_INFO,value="${CIRCLE_SHA1}_${CIRCLE_BUILD_NUM}",container=${AWS_RESOURCE_NAME_PREFIX_FARGATE}-service,name=BUILD_DATE,value=$(date)' - # # test the force-new-deployment flag - # force-new-deployment: true - # verify-revision-is-deployed: true - # max-poll-attempts: 40 - # poll-interval: 10 - # context: [CPE_ORBS_AWS] - # post-steps: - # - test-deployment: - # service-name: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-service" - # cluster: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-cluster" - # - aws-ecs/deploy-service-update: - # name: fargate_test-update-service-skip-registration - # docker-image-for-job: cimg/python:3.10.4 - # filters: *filters - # requires: - # - fargate_test-update-service-job - # aws-access-key-id: AWS_ACCESS_KEY_ID - # aws-region: AWS_DEFAULT_REGION - # profile-name: "ECS_TEST_PROFILE" - # family: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-service" - # cluster: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-cluster" - # # test skipping registration of a new task definition - # skip-task-definition-registration: true - # # test the enable-circuit-breaker flag - # enable-circuit-breaker: true - # verify-revision-is-deployed: true - # max-poll-attempts: 40 - # poll-interval: 10 - # context: [CPE_ORBS_AWS] - # - tear-down-test-env: - # name: fargate_tear-down-test-env - # filters: *filters - # requires: - # - fargate_test-update-service-skip-registration - # - test-fargatespot - # aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_FARGATE} - # terraform-config-dir: "tests/terraform_setup/fargate" - # context: [CPE_ORBS_AWS] + - build-test-app: + name: fargate_build-test-app + docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com" + docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}:${CIRCLE_SHA1}" + context: [CPE_ORBS_AWS] + filters: *filters + - set-up-test-env: + name: fargate_set-up-test-env + filters: *filters + requires: + - fargate_build-test-app + aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_FARGATE} + terraform-config-dir: "tests/terraform_setup/fargate" + context: [CPE_ORBS_AWS] + - test-service-update: + name: fargate_test-update-service-command + filters: *filters + requires: + - fargate_set-up-test-env + aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_FARGATE} + family-name: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-service" + service-name: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-service" + docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com" + docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}:${CIRCLE_SHA1}" + context: [CPE_ORBS_AWS] + - aws-ecs/deploy-service-update: + name: fargate_test-update-service-job + docker-image-for-job: cimg/python:3.10.4 + filters: *filters + requires: + - fargate_test-update-service-command + aws-access-key-id: AWS_ACCESS_KEY_ID + aws-region: AWS_DEFAULT_REGION + profile-name: "ECS_TEST_PROFILE" + family: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-service" + cluster: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-cluster" + container-env-var-updates: 'container=${AWS_RESOURCE_NAME_PREFIX_FARGATE}-service,name=VERSION_INFO,value="${CIRCLE_SHA1}_${CIRCLE_BUILD_NUM}",container=${AWS_RESOURCE_NAME_PREFIX_FARGATE}-service,name=BUILD_DATE,value=$(date)' + # test the force-new-deployment flag + force-new-deployment: true + verify-revision-is-deployed: true + max-poll-attempts: 40 + poll-interval: 10 + context: [CPE_ORBS_AWS] + post-steps: + - test-deployment: + service-name: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-service" + cluster: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-cluster" + - aws-ecs/deploy-service-update: + name: fargate_test-update-service-skip-registration + docker-image-for-job: cimg/python:3.10.4 + filters: *filters + requires: + - fargate_test-update-service-job + aws-access-key-id: AWS_ACCESS_KEY_ID + aws-region: AWS_DEFAULT_REGION + profile-name: "ECS_TEST_PROFILE" + family: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-service" + cluster: "${AWS_RESOURCE_NAME_PREFIX_FARGATE}-cluster" + # test skipping registration of a new task definition + skip-task-definition-registration: true + # test the enable-circuit-breaker flag + enable-circuit-breaker: true + verify-revision-is-deployed: true + max-poll-attempts: 40 + poll-interval: 10 + context: [CPE_ORBS_AWS] + - tear-down-test-env: + name: fargate_tear-down-test-env + filters: *filters + requires: + - fargate_test-update-service-skip-registration + - test-fargatespot + aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_FARGATE} + terraform-config-dir: "tests/terraform_setup/fargate" + context: [CPE_ORBS_AWS] ################# # EC2 @@ -519,8 +519,7 @@ workflows: family: "${AWS_RESOURCE_NAME_PREFIX_EC2}-family" service-name: "${AWS_RESOURCE_NAME_PREFIX_EC2}-service" cluster: "${AWS_RESOURCE_NAME_PREFIX_EC2}-cluster" - #container-env-var-updates: 'container=${AWS_RESOURCE_NAME_PREFIX_EC2}-service,name=VERSION_INFO,value="Asterisk * expansion test ${CIRCLE_SHA1}_${CIRCLE_BUILD_NUM}",container=${AWS_RESOURCE_NAME_PREFIX_EC2}-service,name=BUILD_DATE,value=$(date)' - container-env-var-updates: 'container=${AWS_RESOURCE_NAME_PREFIX_EC2}-service,name=VERSION_INFO,value="Asterisk * expansion test ${CIRCLE_SHA1}_${CIRCLE_BUILD_NUM}",container=${AWS_RESOURCE_NAME_PREFIX_EC2}-service,name=BUILD_DATE,value="YmV0dHkgaXMgaG90Cgo="' + container-env-var-updates: 'container=${AWS_RESOURCE_NAME_PREFIX_EC2}-service,name=VERSION_INFO,value="Asterisk * expansion test ${CIRCLE_SHA1}_${CIRCLE_BUILD_NUM}",container=${AWS_RESOURCE_NAME_PREFIX_EC2}-service,name=BUILD_DATE,value=$(date)' verify-revision-is-deployed: true fail-on-verification-timeout: false post-steps: @@ -543,124 +542,124 @@ workflows: # # FargateSpot # ################# - # - test-fargatespot: - # context: [CPE_ORBS_AWS] - # filters: *filters - # requires: - # - fargate_set-up-test-env + - test-fargatespot: + context: [CPE_ORBS_AWS] + filters: *filters + requires: + - fargate_set-up-test-env ################# # CodeDeploy ################# - # - build-test-app: - # name: codedeploy_fargate_build-test-app - # docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com" - # docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}:${CIRCLE_SHA1}" - # context: [CPE_ORBS_AWS] - # filters: *filters - # - set-up-test-env: - # name: codedeploy_fargate_set-up-test-env - # filters: *filters - # requires: - # - codedeploy_fargate_build-test-app - # terraform-image: "hashicorp/terraform:1.1.9" - # aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE} - # terraform-config-dir: "tests/terraform_setup/fargate_codedeploy" - # context: [CPE_ORBS_AWS] - # - test-service-update: - # name: codedeploy_fargate_test-update-service-command - # filters: *filters - # requires: - # - codedeploy_fargate_set-up-test-env - # aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE} - # family-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" - # service-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" - # docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com" - # docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}:${CIRCLE_SHA1}" - # skip-service-update: true - # context: [CPE_ORBS_AWS] - # - aws-ecs/deploy-service-update: - # name: codedeploy_fargate_test-update-service-job - # docker-image-for-job: cimg/python:3.10.4 - # filters: *filters - # requires: - # - codedeploy_fargate_test-update-service-command - # aws-access-key-id: AWS_ACCESS_KEY_ID - # aws-region: AWS_DEFAULT_REGION - # family: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" - # cluster: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-cluster" - # container-image-name-updates: "container=${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service,image-and-tag=${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}:${CIRCLE_SHA1}" - # container-env-var-updates: 'container=${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service,name=VERSION_INFO,value="${CIRCLE_SHA1}_${CIRCLE_BUILD_NUM}",container=${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service,name=BUILD_DATE,value=$(date)' - # deployment-controller: "CODE_DEPLOY" - # codedeploy-application-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-codedeployapp" - # codedeploy-deployment-group-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-codedeploygroup" - # codedeploy-load-balanced-container-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" - # codedeploy-load-balanced-container-port: 8080 - # verify-revision-is-deployed: false - # context: [CPE_ORBS_AWS] - # post-steps: - # - wait-for-codedeploy-deployment: - # application-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-codedeployapp" - # deployment-group-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-codedeploygroup" - # - test-deployment: - # service-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" - # cluster: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-cluster" - # delete-load-balancer: false - # - aws-ecs/deploy-service-update: - # name: codedeploy_fargate_test-update-and-wait-service-job - # docker-image-for-job: cimg/python:3.10.4 - # context: [CPE_ORBS_AWS] - # filters: *filters - # requires: - # - codedeploy_fargate_test-update-service-job - # aws-access-key-id: AWS_ACCESS_KEY_ID - # aws-region: AWS_DEFAULT_REGION - # family: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" - # cluster: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-cluster" - # container-image-name-updates: "container=${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service,image-and-tag=${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}:${CIRCLE_SHA1}" - # container-env-var-updates: 'container=${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service,name=VERSION_INFO,value="${CIRCLE_SHA1}_${CIRCLE_BUILD_NUM}",container=${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service,name=BUILD_DATE,value=$(date)' - # deployment-controller: "CODE_DEPLOY" - # codedeploy-application-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-codedeployapp" - # codedeploy-deployment-group-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-codedeploygroup" - # codedeploy-load-balanced-container-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" - # codedeploy-load-balanced-container-port: 8080 - # verify-revision-is-deployed: true - # verification-timeout: "12m" - # post-steps: - # - test-deployment: - # service-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" - # cluster: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-cluster" - # delete-load-balancer: true - # - delete-service: - # service-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" - # cluster: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-cluster" - # - tear-down-test-env: - # name: codedeploy_fargate_tear-down-test-env - # requires: - # - codedeploy_fargate_test-update-and-wait-service-job - # terraform-image: "hashicorp/terraform:1.1.9" - # aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE} - # terraform-config-dir: "tests/terraform_setup/fargate_codedeploy" - # context: [CPE_ORBS_AWS] - # filters: *filters - # - orb-tools/pack: - # filters: *filters - # - orb-tools/publish: - # orb-name: circleci/aws-ecs - # vcs-type: << pipeline.project.type >> - # pub-type: production - # requires: - # - orb-tools/pack - # - ec2_tear-down-test-env - # - fargate_tear-down-test-env - # - codedeploy_fargate_tear-down-test-env - # - integration-test-ecs-cli-install - # context: orb-publisher - # filters: - # branches: - # ignore: /.*/ - # tags: - # only: /^v[0-9]+\.[0-9]+\.[0-9]+$/ + - build-test-app: + name: codedeploy_fargate_build-test-app + docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com" + docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}:${CIRCLE_SHA1}" + context: [CPE_ORBS_AWS] + filters: *filters + - set-up-test-env: + name: codedeploy_fargate_set-up-test-env + filters: *filters + requires: + - codedeploy_fargate_build-test-app + terraform-image: "hashicorp/terraform:1.1.9" + aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE} + terraform-config-dir: "tests/terraform_setup/fargate_codedeploy" + context: [CPE_ORBS_AWS] + - test-service-update: + name: codedeploy_fargate_test-update-service-command + filters: *filters + requires: + - codedeploy_fargate_set-up-test-env + aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE} + family-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" + service-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" + docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com" + docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}:${CIRCLE_SHA1}" + skip-service-update: true + context: [CPE_ORBS_AWS] + - aws-ecs/deploy-service-update: + name: codedeploy_fargate_test-update-service-job + docker-image-for-job: cimg/python:3.10.4 + filters: *filters + requires: + - codedeploy_fargate_test-update-service-command + aws-access-key-id: AWS_ACCESS_KEY_ID + aws-region: AWS_DEFAULT_REGION + family: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" + cluster: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-cluster" + container-image-name-updates: "container=${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service,image-and-tag=${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}:${CIRCLE_SHA1}" + container-env-var-updates: 'container=${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service,name=VERSION_INFO,value="${CIRCLE_SHA1}_${CIRCLE_BUILD_NUM}",container=${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service,name=BUILD_DATE,value=$(date)' + deployment-controller: "CODE_DEPLOY" + codedeploy-application-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-codedeployapp" + codedeploy-deployment-group-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-codedeploygroup" + codedeploy-load-balanced-container-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" + codedeploy-load-balanced-container-port: 8080 + verify-revision-is-deployed: false + context: [CPE_ORBS_AWS] + post-steps: + - wait-for-codedeploy-deployment: + application-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-codedeployapp" + deployment-group-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-codedeploygroup" + - test-deployment: + service-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" + cluster: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-cluster" + delete-load-balancer: false + - aws-ecs/deploy-service-update: + name: codedeploy_fargate_test-update-and-wait-service-job + docker-image-for-job: cimg/python:3.10.4 + context: [CPE_ORBS_AWS] + filters: *filters + requires: + - codedeploy_fargate_test-update-service-job + aws-access-key-id: AWS_ACCESS_KEY_ID + aws-region: AWS_DEFAULT_REGION + family: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" + cluster: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-cluster" + container-image-name-updates: "container=${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service,image-and-tag=${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}:${CIRCLE_SHA1}" + container-env-var-updates: 'container=${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service,name=VERSION_INFO,value="${CIRCLE_SHA1}_${CIRCLE_BUILD_NUM}",container=${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service,name=BUILD_DATE,value=$(date)' + deployment-controller: "CODE_DEPLOY" + codedeploy-application-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-codedeployapp" + codedeploy-deployment-group-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-codedeploygroup" + codedeploy-load-balanced-container-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" + codedeploy-load-balanced-container-port: 8080 + verify-revision-is-deployed: true + verification-timeout: "12m" + post-steps: + - test-deployment: + service-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" + cluster: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-cluster" + delete-load-balancer: true + - delete-service: + service-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" + cluster: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-cluster" + - tear-down-test-env: + name: codedeploy_fargate_tear-down-test-env + requires: + - codedeploy_fargate_test-update-and-wait-service-job + terraform-image: "hashicorp/terraform:1.1.9" + aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE} + terraform-config-dir: "tests/terraform_setup/fargate_codedeploy" + context: [CPE_ORBS_AWS] + filters: *filters + - orb-tools/pack: + filters: *filters + - orb-tools/publish: + orb-name: circleci/aws-ecs + vcs-type: << pipeline.project.type >> + pub-type: production + requires: + - orb-tools/pack + - ec2_tear-down-test-env + - fargate_tear-down-test-env + - codedeploy_fargate_tear-down-test-env + - integration-test-ecs-cli-install + context: orb-publisher + filters: + branches: + ignore: /.*/ + tags: + only: /^v[0-9]+\.[0-9]+\.[0-9]+$/ commands: wait-for-codedeploy-deployment: description: "Wait for the CodeDeploy deployment to be successful" diff --git a/src/jobs/deploy-service-update.yml b/src/jobs/deploy-service-update.yml index 2382b926..49ea4063 100644 --- a/src/jobs/deploy-service-update.yml +++ b/src/jobs/deploy-service-update.yml @@ -212,5 +212,3 @@ steps: task-definition-tags: << parameters.task-definition-tags >> verification-timeout: << parameters.verification-timeout >> profile-name: << parameters.profile-name >> - - store_artifacts: - path: test.txt diff --git a/src/scripts/get-prev-task.sh b/src/scripts/get-prev-task.sh index 4540b015..a8ba99cd 100644 --- a/src/scripts/get-prev-task.sh +++ b/src/scripts/get-prev-task.sh @@ -30,19 +30,10 @@ cat <<< "$ECS_SCRIPT_UPDATE_CONTAINER_DEFS" > "$UPDATE_CONTAINER_DEFS_SCRIPT_FIL # Prepare container definitions CONTAINER_DEFS=$(python "$UPDATE_CONTAINER_DEFS_SCRIPT_FILE" "$PREVIOUS_TASK_DEFINITION" "$ECS_PARAM_CONTAINER_IMAGE_NAME_UPDATES" "$ECS_PARAM_CONTAINER_ENV_VAR_UPDATES") -{ - echo "PTD: ${PREVIOUS_TASK_DEFINITION}" - echo "CINU: ${ECS_PARAM_CONTAINER_IMAGE_NAME_UPDATES}" - echo "CEVU: ${ECS_PARAM_CONTAINER_ENV_VAR_UPDATES}" -} >> test.txt # Escape single quotes from environment variables for BASH_ENV CLEANED_CONTAINER_DEFS=$(echo "$CONTAINER_DEFS" | sed -E "s:':'\\\'':g") -{ - echo "CCD: ${CLEANED_CONTAINER_DEFS}" -} >> test.txt - # Prepare script for getting task definition values GET_TASK_DFN_VAL_SCRIPT_FILE=$(mktemp _get_task_def_value.py.XXXXXX) @@ -108,7 +99,6 @@ echo "export CCI_ORB_AWS_ECS_TAGS='${TAGS}'" >> "$BASH_ENV" echo "export CCI_ORB_AWS_ECS_PROXY_CONFIGURATION='${PROXY_CONFIGURATION}'" >> "$BASH_ENV" -echo "RP: ${RUNTIME_PLATFORM}" >> test.txt echo "export CCI_ORB_AWS_ECS_RUNTIME_PLATFORM='${RUNTIME_PLATFORM}'" >> "$BASH_ENV" rm "$UPDATE_CONTAINER_DEFS_SCRIPT_FILE" "$GET_TASK_DFN_VAL_SCRIPT_FILE"