From 900373d32835794924f39ffc81ff2469f94e7681 Mon Sep 17 00:00:00 2001 From: Brian Vu Date: Wed, 8 Jun 2022 00:49:13 -0700 Subject: [PATCH 1/5] feat: implemented run-task-output parameter --- src/commands/run-task.yml | 5 +++++ src/jobs/run-task.yml | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/commands/run-task.yml b/src/commands/run-task.yml index 689098c5..d9ef2156 100755 --- a/src/commands/run-task.yml +++ b/src/commands/run-task.yml @@ -113,6 +113,10 @@ parameters: description: AWS profile name to be configured. type: string default: '' + run-task-output: + description: | + Specifies a local file on to save the output from the aws ecs run-task command. + type: string steps: - run: name: Run Task @@ -137,3 +141,4 @@ steps: ECS_PARAM_PROPAGATE_TAGS: <> ECS_PARAM_CAPACITY_PROVIDER_STRATEGY: <> ECS_PARAM_PROFILE_NAME: <> + ECS_PARAM_RUN_OUTPUT: <> diff --git a/src/jobs/run-task.yml b/src/jobs/run-task.yml index ca15746e..aa62c725 100755 --- a/src/jobs/run-task.yml +++ b/src/jobs/run-task.yml @@ -149,6 +149,10 @@ parameters: If a `capacity-provider-strategy` is specified, the `launch-type` parameter must be set to an empty string. type: string default: "" + run-task-output: + description: | + Specifies a local file on to save the output from the aws ecs run-task command. + type: string steps: - aws-cli/setup: aws-access-key-id: << parameters.aws-access-key-id >> @@ -175,3 +179,4 @@ steps: propagate-tags: << parameters.propagate-tags >> capacity-provider-strategy: << parameters.capacity-provider-strategy >> profile-name: << parameters.profile-name >> + run-task-output: <> From b26ce0baf150a75e96a8a8ef9b0b2d97a4887d8e Mon Sep 17 00:00:00 2001 From: Brian Vu Date: Wed, 8 Jun 2022 00:49:33 -0700 Subject: [PATCH 2/5] ci: added testing for run-task-output parameter --- .circleci/test-deploy.yml | 361 +++++++++++++++++++------------------- src/commands/run-task.yml | 3 +- src/jobs/run-task.yml | 5 +- src/scripts/run-task.sh | 4 +- 4 files changed, 190 insertions(+), 183 deletions(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 7a9b8ea4..bf36f4c2 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -359,90 +359,90 @@ workflows: test-deploy: jobs: # Make sure to include "filters: *filters" in every test job you want to run as part of your deployment. - - integration-test-ecs-cli-install: - version: "v1.9.0" - matrix: - parameters: - executor: [linux, mac] - filters: *filters + # - integration-test-ecs-cli-install: + # version: "v1.9.0" + # matrix: + # parameters: + # executor: [linux, mac] + # filters: *filters ################# # 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-name: "${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-name: "${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-name: "${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-name: "${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-name: "${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-name: "${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 @@ -478,6 +478,7 @@ workflows: task-definition: "${AWS_RESOURCE_NAME_PREFIX_EC2}-sleep360" launch-type: "EC2" awsvpc: false + run-task-output: "run-task-output.json" overrides: '{"containerOverrides":[{"name": "${INTERPOLATION_TEST}", "memory": 512}]}' context: [CPE_ORBS_AWS] - tear-down-run-task-test: @@ -541,106 +542,106 @@ 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-name: "${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-name: "${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-name: "${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-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-cluster" - delete-load-balancer: true - - delete-service: - service-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" - cluster-name: "${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 + # - 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-name: "${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-name: "${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-name: "${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-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-cluster" + # delete-load-balancer: true + # - delete-service: + # service-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" + # cluster-name: "${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: @@ -650,9 +651,9 @@ workflows: 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 + # - fargate_tear-down-test-env + # - codedeploy_fargate_tear-down-test-env + # - integration-test-ecs-cli-install context: orb-publisher filters: branches: diff --git a/src/commands/run-task.yml b/src/commands/run-task.yml index d9ef2156..2085211b 100755 --- a/src/commands/run-task.yml +++ b/src/commands/run-task.yml @@ -117,6 +117,7 @@ parameters: description: | Specifies a local file on to save the output from the aws ecs run-task command. type: string + default: '' steps: - run: name: Run Task @@ -141,4 +142,4 @@ steps: ECS_PARAM_PROPAGATE_TAGS: <> ECS_PARAM_CAPACITY_PROVIDER_STRATEGY: <> ECS_PARAM_PROFILE_NAME: <> - ECS_PARAM_RUN_OUTPUT: <> + ECS_PARAM_RUN_TASK_OUTPUT: <> diff --git a/src/jobs/run-task.yml b/src/jobs/run-task.yml index aa62c725..556239c0 100755 --- a/src/jobs/run-task.yml +++ b/src/jobs/run-task.yml @@ -152,7 +152,8 @@ parameters: run-task-output: description: | Specifies a local file on to save the output from the aws ecs run-task command. - type: string + type: string + default: '' steps: - aws-cli/setup: aws-access-key-id: << parameters.aws-access-key-id >> @@ -180,3 +181,5 @@ steps: capacity-provider-strategy: << parameters.capacity-provider-strategy >> profile-name: << parameters.profile-name >> run-task-output: <> + - store_artifacts: + path: run-task-output.json diff --git a/src/scripts/run-task.sh b/src/scripts/run-task.sh index 6c945727..33fa15d7 100644 --- a/src/scripts/run-task.sh +++ b/src/scripts/run-task.sh @@ -88,5 +88,7 @@ echo "Setting --task-definition" set -- "$@" --task-definition "$ECS_PARAM_TASK_DEF" echo "Setting --cluster" set -- "$@" --cluster "$ECS_PARAM_CLUSTER_NAME" - +if [ -n "${ECS_PARAM_RUN_TASK_OUTPUT}" ]; then + aws ecs run-task "$@" >> "${ECS_PARAM_RUN_TASK_OUTPUT}" +fi aws ecs run-task "$@" From 9e75060f6aa73bb35c3bf2d5951aca85a868ff05 Mon Sep 17 00:00:00 2001 From: Brian Vu Date: Thu, 9 Jun 2022 11:29:07 -0700 Subject: [PATCH 3/5] chore: code cleanup --- .circleci/test-deploy.yml | 360 +++++++++++++++++++------------------- src/jobs/run-task.yml | 2 - src/scripts/run-task.sh | 1 + 3 files changed, 181 insertions(+), 182 deletions(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index bf36f4c2..541cfabd 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -359,90 +359,90 @@ workflows: test-deploy: jobs: # Make sure to include "filters: *filters" in every test job you want to run as part of your deployment. - # - integration-test-ecs-cli-install: - # version: "v1.9.0" - # matrix: - # parameters: - # executor: [linux, mac] - # filters: *filters + - integration-test-ecs-cli-install: + version: "v1.9.0" + matrix: + parameters: + executor: [linux, mac] + filters: *filters ################# # 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-name: "${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-name: "${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-name: "${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-name: "${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-name: "${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-name: "${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 @@ -542,106 +542,106 @@ 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-name: "${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-name: "${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-name: "${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-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-cluster" - # delete-load-balancer: true - # - delete-service: - # service-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" - # cluster-name: "${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 + - 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-name: "${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-name: "${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-name: "${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-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-cluster" + delete-load-balancer: true + - delete-service: + service-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}-service" + cluster-name: "${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: @@ -651,9 +651,9 @@ workflows: 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 + - fargate_tear-down-test-env + - codedeploy_fargate_tear-down-test-env + - integration-test-ecs-cli-install context: orb-publisher filters: branches: diff --git a/src/jobs/run-task.yml b/src/jobs/run-task.yml index 556239c0..154eed14 100755 --- a/src/jobs/run-task.yml +++ b/src/jobs/run-task.yml @@ -181,5 +181,3 @@ steps: capacity-provider-strategy: << parameters.capacity-provider-strategy >> profile-name: << parameters.profile-name >> run-task-output: <> - - store_artifacts: - path: run-task-output.json diff --git a/src/scripts/run-task.sh b/src/scripts/run-task.sh index 33fa15d7..22681d63 100644 --- a/src/scripts/run-task.sh +++ b/src/scripts/run-task.sh @@ -88,6 +88,7 @@ echo "Setting --task-definition" set -- "$@" --task-definition "$ECS_PARAM_TASK_DEF" echo "Setting --cluster" set -- "$@" --cluster "$ECS_PARAM_CLUSTER_NAME" + if [ -n "${ECS_PARAM_RUN_TASK_OUTPUT}" ]; then aws ecs run-task "$@" >> "${ECS_PARAM_RUN_TASK_OUTPUT}" fi From b14dc921e676a232dfaf5d9b965b4224a936d928 Mon Sep 17 00:00:00 2001 From: Brian Vu Date: Thu, 9 Jun 2022 12:44:22 -0700 Subject: [PATCH 4/5] chore: edited paramater description --- src/commands/run-task.yml | 2 +- src/jobs/run-task.yml | 2 +- src/scripts/run-task.sh | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/commands/run-task.yml b/src/commands/run-task.yml index 2085211b..68141d34 100755 --- a/src/commands/run-task.yml +++ b/src/commands/run-task.yml @@ -115,7 +115,7 @@ parameters: default: '' run-task-output: description: | - Specifies a local file on to save the output from the aws ecs run-task command. + Specifies a local json file to save the output logs from the aws ecs run-task command. This will enable users to extract information like task-arn's, task-id's and more from the output. type: string default: '' steps: diff --git a/src/jobs/run-task.yml b/src/jobs/run-task.yml index 154eed14..f93f55b8 100755 --- a/src/jobs/run-task.yml +++ b/src/jobs/run-task.yml @@ -151,7 +151,7 @@ parameters: default: "" run-task-output: description: | - Specifies a local file on to save the output from the aws ecs run-task command. + Specifies a local json file to save the output logs from the aws ecs run-task command. This will enable users to extract information like task-arn's, task-id's and more from the output. type: string default: '' steps: diff --git a/src/scripts/run-task.sh b/src/scripts/run-task.sh index 22681d63..d1d37aad 100644 --- a/src/scripts/run-task.sh +++ b/src/scripts/run-task.sh @@ -91,5 +91,6 @@ set -- "$@" --cluster "$ECS_PARAM_CLUSTER_NAME" if [ -n "${ECS_PARAM_RUN_TASK_OUTPUT}" ]; then aws ecs run-task "$@" >> "${ECS_PARAM_RUN_TASK_OUTPUT}" +else + aws ecs run-task "$@" fi -aws ecs run-task "$@" From cc143694110e7d3beb57ae9a6140dcb872cac350 Mon Sep 17 00:00:00 2001 From: Brian Vu Date: Fri, 10 Jun 2022 11:05:41 -0700 Subject: [PATCH 5/5] fix: edited descriptions and added tee --- src/commands/run-task.yml | 2 +- src/jobs/run-task.yml | 2 +- src/scripts/run-task.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/commands/run-task.yml b/src/commands/run-task.yml index 68141d34..d5af8973 100755 --- a/src/commands/run-task.yml +++ b/src/commands/run-task.yml @@ -115,7 +115,7 @@ parameters: default: '' run-task-output: description: | - Specifies a local json file to save the output logs from the aws ecs run-task command. This will enable users to extract information like task-arn's, task-id's and more from the output. + Specifies a local json file to save the output logs from the aws ecs run-task command. Use tools like JQ to read and parse this information such as "task-arns" and "task-ids" type: string default: '' steps: diff --git a/src/jobs/run-task.yml b/src/jobs/run-task.yml index f93f55b8..3a87c9ec 100755 --- a/src/jobs/run-task.yml +++ b/src/jobs/run-task.yml @@ -151,7 +151,7 @@ parameters: default: "" run-task-output: description: | - Specifies a local json file to save the output logs from the aws ecs run-task command. This will enable users to extract information like task-arn's, task-id's and more from the output. + Specifies a local json file to save the output logs from the aws ecs run-task command. Use tools like JQ to read and parse this information such as "task-arns" and "task-ids" type: string default: '' steps: diff --git a/src/scripts/run-task.sh b/src/scripts/run-task.sh index d1d37aad..77fa3bfa 100644 --- a/src/scripts/run-task.sh +++ b/src/scripts/run-task.sh @@ -90,7 +90,7 @@ echo "Setting --cluster" set -- "$@" --cluster "$ECS_PARAM_CLUSTER_NAME" if [ -n "${ECS_PARAM_RUN_TASK_OUTPUT}" ]; then - aws ecs run-task "$@" >> "${ECS_PARAM_RUN_TASK_OUTPUT}" + aws ecs run-task "$@" | tee "${ECS_PARAM_RUN_TASK_OUTPUT}" else aws ecs run-task "$@" fi