From 26c7098115be9ba7898d8a615e2b9a9aa1d5e624 Mon Sep 17 00:00:00 2001 From: Paul Ocen Date: Sun, 29 Dec 2019 20:01:37 +0300 Subject: [PATCH 1/8] Set an optional parameter on whether to run update-task-definition during update-service task. --- src/orb.yml.hbs | 73 +++++++++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 32 deletions(-) diff --git a/src/orb.yml.hbs b/src/orb.yml.hbs index c9212c30..367f645b 100644 --- a/src/orb.yml.hbs +++ b/src/orb.yml.hbs @@ -848,42 +848,51 @@ commands: Only in use when verify-revision-is-deployed is set to true. type: boolean default: true + run-update-task-definition: + description: | + Whether to run the update-task-definition again in the update-service or + not. Defaults to false and will only run when parameter is set to true. + type: boolean + default: false steps: - - update-task-definition: - family: << parameters.family >> - container-image-name-updates: << parameters.container-image-name-updates >> - container-env-var-updates: << parameters.container-env-var-updates >> - - run: - name: Update service with registered task definition - command: | - DEPLOYMENT_CONTROLLER="$(echo << parameters.deployment-controller >>)" + - when: + condition: <> + steps: + - update-task-definition: + family: << parameters.family >> + container-image-name-updates: << parameters.container-image-name-updates >> + container-env-var-updates: << parameters.container-env-var-updates >> + - run: + name: Update service with registered task definition + command: | + DEPLOYMENT_CONTROLLER="$(echo << parameters.deployment-controller >>)" - if [ "${DEPLOYMENT_CONTROLLER}" = "CODE_DEPLOY" ]; then - DEPLOYED_REVISION="${CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN}" - DEPLOYMENT_ID=$(aws deploy create-deployment \ - --application-name "<< parameters.codedeploy-application-name >>" \ - --deployment-group-name "<< parameters.codedeploy-deployment-group-name >>" \ - --revision "{\"revisionType\": \"AppSpecContent\", \"appSpecContent\": {\"content\": \"{\\\"version\\\": 1, \\\"Resources\\\": [{\\\"TargetService\\\": {\\\"Type\\\": \\\"AWS::ECS::Service\\\", \\\"Properties\\\": {\\\"TaskDefinition\\\": \\\"${CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN}\\\", \\\"LoadBalancerInfo\\\": {\\\"ContainerName\\\": \\\"<< parameters.codedeploy-load-balanced-container-name >>\\\", \\\"ContainerPort\\\": << parameters.codedeploy-load-balanced-container-port >>}}}}]}\"}}" \ - --query deploymentId) - echo "Created CodeDeploy deployment: $DEPLOYMENT_ID" - else - SERVICE_NAME="$(echo << parameters.service-name >>)" + if [ "${DEPLOYMENT_CONTROLLER}" = "CODE_DEPLOY" ]; then + DEPLOYED_REVISION="${CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN}" + DEPLOYMENT_ID=$(aws deploy create-deployment \ + --application-name "<< parameters.codedeploy-application-name >>" \ + --deployment-group-name "<< parameters.codedeploy-deployment-group-name >>" \ + --revision "{\"revisionType\": \"AppSpecContent\", \"appSpecContent\": {\"content\": \"{\\\"version\\\": 1, \\\"Resources\\\": [{\\\"TargetService\\\": {\\\"Type\\\": \\\"AWS::ECS::Service\\\", \\\"Properties\\\": {\\\"TaskDefinition\\\": \\\"${CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN}\\\", \\\"LoadBalancerInfo\\\": {\\\"ContainerName\\\": \\\"<< parameters.codedeploy-load-balanced-container-name >>\\\", \\\"ContainerPort\\\": << parameters.codedeploy-load-balanced-container-port >>}}}}]}\"}}" \ + --query deploymentId) + echo "Created CodeDeploy deployment: $DEPLOYMENT_ID" + else + SERVICE_NAME="$(echo << parameters.service-name >>)" - if [ -z "${SERVICE_NAME}" ]; then - SERVICE_NAME="$(echo << parameters.family >>)" - fi - if [ "<< parameters.force-new-deployment >>" == "true" ]; then - set -- "$@" --force-new-deployment + if [ -z "${SERVICE_NAME}" ]; then + SERVICE_NAME="$(echo << parameters.family >>)" + fi + if [ "<< parameters.force-new-deployment >>" == "true" ]; then + set -- "$@" --force-new-deployment + fi + DEPLOYED_REVISION=$(aws ecs update-service \ + --cluster "<< parameters.cluster-name >>" \ + --service "${SERVICE_NAME}" \ + --task-definition "${CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN}" \ + --output text \ + --query service.taskDefinition \ + "$@") fi - DEPLOYED_REVISION=$(aws ecs update-service \ - --cluster "<< parameters.cluster-name >>" \ - --service "${SERVICE_NAME}" \ - --task-definition "${CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN}" \ - --output text \ - --query service.taskDefinition \ - "$@") - fi - echo "export CCI_ORB_AWS_ECS_DEPLOYED_REVISION='${DEPLOYED_REVISION}'" >> $BASH_ENV + echo "export CCI_ORB_AWS_ECS_DEPLOYED_REVISION='${DEPLOYED_REVISION}'" >> $BASH_ENV - when: condition: << parameters.verify-revision-is-deployed >> steps: From 3e2329b5484c1cb59f33f0f61b2497214a5bc57c Mon Sep 17 00:00:00 2001 From: Paul Ocen Date: Sun, 29 Dec 2019 20:37:27 +0300 Subject: [PATCH 2/8] Update linting of the file. --- src/orb.yml.hbs | 70 ++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/orb.yml.hbs b/src/orb.yml.hbs index 367f645b..5d3167ee 100644 --- a/src/orb.yml.hbs +++ b/src/orb.yml.hbs @@ -856,43 +856,43 @@ commands: default: false steps: - when: - condition: <> - steps: - - update-task-definition: - family: << parameters.family >> - container-image-name-updates: << parameters.container-image-name-updates >> - container-env-var-updates: << parameters.container-env-var-updates >> - - run: - name: Update service with registered task definition - command: | - DEPLOYMENT_CONTROLLER="$(echo << parameters.deployment-controller >>)" + condition: <> + steps: + - update-task-definition: + family: << parameters.family >> + container-image-name-updates: << parameters.container-image-name-updates >> + container-env-var-updates: << parameters.container-env-var-updates >> + - run: + name: Update service with registered task definition + command: | + DEPLOYMENT_CONTROLLER="$(echo << parameters.deployment-controller >>)" - if [ "${DEPLOYMENT_CONTROLLER}" = "CODE_DEPLOY" ]; then - DEPLOYED_REVISION="${CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN}" - DEPLOYMENT_ID=$(aws deploy create-deployment \ - --application-name "<< parameters.codedeploy-application-name >>" \ - --deployment-group-name "<< parameters.codedeploy-deployment-group-name >>" \ - --revision "{\"revisionType\": \"AppSpecContent\", \"appSpecContent\": {\"content\": \"{\\\"version\\\": 1, \\\"Resources\\\": [{\\\"TargetService\\\": {\\\"Type\\\": \\\"AWS::ECS::Service\\\", \\\"Properties\\\": {\\\"TaskDefinition\\\": \\\"${CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN}\\\", \\\"LoadBalancerInfo\\\": {\\\"ContainerName\\\": \\\"<< parameters.codedeploy-load-balanced-container-name >>\\\", \\\"ContainerPort\\\": << parameters.codedeploy-load-balanced-container-port >>}}}}]}\"}}" \ - --query deploymentId) - echo "Created CodeDeploy deployment: $DEPLOYMENT_ID" - else - SERVICE_NAME="$(echo << parameters.service-name >>)" + if [ "${DEPLOYMENT_CONTROLLER}" = "CODE_DEPLOY" ]; then + DEPLOYED_REVISION="${CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN}" + DEPLOYMENT_ID=$(aws deploy create-deployment \ + --application-name "<< parameters.codedeploy-application-name >>" \ + --deployment-group-name "<< parameters.codedeploy-deployment-group-name >>" \ + --revision "{\"revisionType\": \"AppSpecContent\", \"appSpecContent\": {\"content\": \"{\\\"version\\\": 1, \\\"Resources\\\": [{\\\"TargetService\\\": {\\\"Type\\\": \\\"AWS::ECS::Service\\\", \\\"Properties\\\": {\\\"TaskDefinition\\\": \\\"${CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN}\\\", \\\"LoadBalancerInfo\\\": {\\\"ContainerName\\\": \\\"<< parameters.codedeploy-load-balanced-container-name >>\\\", \\\"ContainerPort\\\": << parameters.codedeploy-load-balanced-container-port >>}}}}]}\"}}" \ + --query deploymentId) + echo "Created CodeDeploy deployment: $DEPLOYMENT_ID" + else + SERVICE_NAME="$(echo << parameters.service-name >>)" - if [ -z "${SERVICE_NAME}" ]; then - SERVICE_NAME="$(echo << parameters.family >>)" - fi - if [ "<< parameters.force-new-deployment >>" == "true" ]; then - set -- "$@" --force-new-deployment - fi - DEPLOYED_REVISION=$(aws ecs update-service \ - --cluster "<< parameters.cluster-name >>" \ - --service "${SERVICE_NAME}" \ - --task-definition "${CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN}" \ - --output text \ - --query service.taskDefinition \ - "$@") - fi - echo "export CCI_ORB_AWS_ECS_DEPLOYED_REVISION='${DEPLOYED_REVISION}'" >> $BASH_ENV + if [ -z "${SERVICE_NAME}" ]; then + SERVICE_NAME="$(echo << parameters.family >>)" + fi + if [ "<< parameters.force-new-deployment >>" == "true" ]; then + set -- "$@" --force-new-deployment + fi + DEPLOYED_REVISION=$(aws ecs update-service \ + --cluster "<< parameters.cluster-name >>" \ + --service "${SERVICE_NAME}" \ + --task-definition "${CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN}" \ + --output text \ + --query service.taskDefinition \ + "$@") + fi + echo "export CCI_ORB_AWS_ECS_DEPLOYED_REVISION='${DEPLOYED_REVISION}'" >> $BASH_ENV - when: condition: << parameters.verify-revision-is-deployed >> steps: From 0b5289884244c06573cfda5e9cfaab4914ec3561 Mon Sep 17 00:00:00 2001 From: Paul Ocean Date: Tue, 12 May 2020 14:15:30 +0300 Subject: [PATCH 3/8] Replace the run-update-task-definition with skip-task-definition-registration and update the steps. --- src/orb.yml.hbs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/orb.yml.hbs b/src/orb.yml.hbs index 5d3167ee..4abd146a 100644 --- a/src/orb.yml.hbs +++ b/src/orb.yml.hbs @@ -848,15 +848,14 @@ commands: Only in use when verify-revision-is-deployed is set to true. type: boolean default: true - run-update-task-definition: + skip-task-definition-registration: description: | - Whether to run the update-task-definition again in the update-service or - not. Defaults to false and will only run when parameter is set to true. + Whether to skip registration of a new task definition. type: boolean default: false steps: - - when: - condition: <> + - unless: + condition: << parameters.skip-task-definition-registration >> steps: - update-task-definition: family: << parameters.family >> From 45999bebf2d76420e2457c75025b468c53f2d39f Mon Sep 17 00:00:00 2001 From: Paul Ocean Date: Tue, 12 May 2020 15:11:03 +0300 Subject: [PATCH 4/8] Update deploy-service-update to add the new param and include an additional step to retrieve previous task definition. --- src/orb.yml.hbs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/orb.yml.hbs b/src/orb.yml.hbs index 4abd146a..191a9b07 100644 --- a/src/orb.yml.hbs +++ b/src/orb.yml.hbs @@ -273,6 +273,11 @@ jobs: Only in use when verify-revision-is-deployed is set to true. type: boolean default: true + skip-task-definition-registration: + description: | + Whether to skip registration of a new task definition. + type: boolean + default: false steps: - aws-cli/install - aws-cli/configure: @@ -295,6 +300,7 @@ jobs: max-poll-attempts: << parameters.max-poll-attempts >> poll-interval: << parameters.poll-interval >> fail-on-verification-timeout: << parameters.fail-on-verification-timeout >> + skip-task-definition-registration: << parameters.skip-task-definition-registration >> update-task-definition: docker: - image: << parameters.docker-image-for-job >> @@ -861,6 +867,14 @@ commands: family: << parameters.family >> container-image-name-updates: << parameters.container-image-name-updates >> container-env-var-updates: << parameters.container-env-var-updates >> + - run: + name: Retrieve previous task definition + command: | + TASK_DEFINITION_ARN=$(aws ecs describe-task-definition \ + --task-definition << parameters.family >> \ + --output text \ + --query 'taskDefinition.taskDefinitionArn') + echo "export CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN='${TASK_DEFINITION_ARN}'" >> $BASH_ENV - run: name: Update service with registered task definition command: | From 93a9a1fd8f7a355509c504484ecd2cf3226e5fe4 Mon Sep 17 00:00:00 2001 From: Stella Lok Date: Thu, 4 Jun 2020 19:16:14 +0800 Subject: [PATCH 5/8] "retrieve previous task definition" step should only occur when task definition registration is skipped --- src/orb.yml.hbs | 61 ++++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/src/orb.yml.hbs b/src/orb.yml.hbs index 4b4c2bf8..1fbc39d4 100644 --- a/src/orb.yml.hbs +++ b/src/orb.yml.hbs @@ -948,6 +948,9 @@ commands: family: << parameters.family >> container-image-name-updates: << parameters.container-image-name-updates >> container-env-var-updates: << parameters.container-env-var-updates >> + - when: + condition: << parameters.skip-task-definition-registration >> + steps: - run: name: Retrieve previous task definition command: | @@ -956,37 +959,37 @@ commands: --output text \ --query 'taskDefinition.taskDefinitionArn') echo "export CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN='${TASK_DEFINITION_ARN}'" >> $BASH_ENV - - run: - name: Update service with registered task definition - command: | - DEPLOYMENT_CONTROLLER="$(echo << parameters.deployment-controller >>)" + - run: + name: Update service with registered task definition + command: | + DEPLOYMENT_CONTROLLER="$(echo << parameters.deployment-controller >>)" - if [ "${DEPLOYMENT_CONTROLLER}" = "CODE_DEPLOY" ]; then - DEPLOYED_REVISION="${CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN}" - DEPLOYMENT_ID=$(aws deploy create-deployment \ - --application-name "<< parameters.codedeploy-application-name >>" \ - --deployment-group-name "<< parameters.codedeploy-deployment-group-name >>" \ - --revision "{\"revisionType\": \"AppSpecContent\", \"appSpecContent\": {\"content\": \"{\\\"version\\\": 1, \\\"Resources\\\": [{\\\"TargetService\\\": {\\\"Type\\\": \\\"AWS::ECS::Service\\\", \\\"Properties\\\": {\\\"TaskDefinition\\\": \\\"${CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN}\\\", \\\"LoadBalancerInfo\\\": {\\\"ContainerName\\\": \\\"<< parameters.codedeploy-load-balanced-container-name >>\\\", \\\"ContainerPort\\\": << parameters.codedeploy-load-balanced-container-port >>}}}}]}\"}}" \ - --query deploymentId) - echo "Created CodeDeploy deployment: $DEPLOYMENT_ID" - else - SERVICE_NAME="$(echo << parameters.service-name >>)" + if [ "${DEPLOYMENT_CONTROLLER}" = "CODE_DEPLOY" ]; then + DEPLOYED_REVISION="${CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN}" + DEPLOYMENT_ID=$(aws deploy create-deployment \ + --application-name "<< parameters.codedeploy-application-name >>" \ + --deployment-group-name "<< parameters.codedeploy-deployment-group-name >>" \ + --revision "{\"revisionType\": \"AppSpecContent\", \"appSpecContent\": {\"content\": \"{\\\"version\\\": 1, \\\"Resources\\\": [{\\\"TargetService\\\": {\\\"Type\\\": \\\"AWS::ECS::Service\\\", \\\"Properties\\\": {\\\"TaskDefinition\\\": \\\"${CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN}\\\", \\\"LoadBalancerInfo\\\": {\\\"ContainerName\\\": \\\"<< parameters.codedeploy-load-balanced-container-name >>\\\", \\\"ContainerPort\\\": << parameters.codedeploy-load-balanced-container-port >>}}}}]}\"}}" \ + --query deploymentId) + echo "Created CodeDeploy deployment: $DEPLOYMENT_ID" + else + SERVICE_NAME="$(echo << parameters.service-name >>)" - if [ -z "${SERVICE_NAME}" ]; then - SERVICE_NAME="$(echo << parameters.family >>)" - fi - if [ "<< parameters.force-new-deployment >>" == "true" ]; then - set -- "$@" --force-new-deployment - fi - DEPLOYED_REVISION=$(aws ecs update-service \ - --cluster "<< parameters.cluster-name >>" \ - --service "${SERVICE_NAME}" \ - --task-definition "${CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN}" \ - --output text \ - --query service.taskDefinition \ - "$@") - fi - echo "export CCI_ORB_AWS_ECS_DEPLOYED_REVISION='${DEPLOYED_REVISION}'" >> $BASH_ENV + if [ -z "${SERVICE_NAME}" ]; then + SERVICE_NAME="$(echo << parameters.family >>)" + fi + if [ "<< parameters.force-new-deployment >>" == "true" ]; then + set -- "$@" --force-new-deployment + fi + DEPLOYED_REVISION=$(aws ecs update-service \ + --cluster "<< parameters.cluster-name >>" \ + --service "${SERVICE_NAME}" \ + --task-definition "${CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN}" \ + --output text \ + --query service.taskDefinition \ + "$@") + fi + echo "export CCI_ORB_AWS_ECS_DEPLOYED_REVISION='${DEPLOYED_REVISION}'" >> $BASH_ENV - when: condition: << parameters.verify-revision-is-deployed >> steps: From e933d25f0ef74188eb4219ab8c0e448b14e991ab Mon Sep 17 00:00:00 2001 From: Stella Lok Date: Thu, 4 Jun 2020 19:55:01 +0800 Subject: [PATCH 6/8] test skipping of task definition registration update dev docs --- .circleci/config.yml | 21 +++++++++++++- dev-docs/README.md | 67 +++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 83 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ad1d11f9..2395fb11 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -625,6 +625,25 @@ workflows: 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: circleci/python:3.4.9 + requires: + - fargate_test-update-service-job + aws-access-key-id: "${AWS_ACCESS_KEY_ID}" + aws-region: "${AWS_DEFAULT_REGION}" + 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: false + verify-revision-is-deployed: true + max-poll-attempts: 40 + poll-interval: 10 + 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: codedeploy_fargate_test-update-service-job docker-image-for-job: circleci/python:3.4.9 @@ -666,7 +685,7 @@ workflows: - tear-down-test-env: name: fargate_tear-down-test-env requires: - - fargate_test-update-service-job + - fargate_test-update-service-skip-registration aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_FARGATE} terraform-config-dir: "tests/terraform_setup/fargate" diff --git a/dev-docs/README.md b/dev-docs/README.md index 799d64af..029ea8c8 100644 --- a/dev-docs/README.md +++ b/dev-docs/README.md @@ -12,15 +12,74 @@ The following [project environment variables](https://circleci.com/docs/2.0/env- | -------------------------------| --------------------------------------| | `AWS_ACCESS_KEY_ID` | Picked up by the AWS CLI | | `AWS_SECRET_ACCESS_KEY` | Picked up by the AWS CLI | -| `AWS_DEFAULT_REGION` | Picked up by the AWS CLI | +| `AWS_DEFAULT_REGION` | Picked up by the AWS CLI. Set to `us-east-1`. | | `AWS_ACCOUNT_ID` | AWS account id | | `CIRCLECI_API_KEY` | Used by the `queue` orb | -| `AWS_RESOURCE_NAME_PREFIX_EC2` | Prefix used to name AWS resources for EC2 launch type integration tests | -| `AWS_RESOURCE_NAME_PREFIX_FARGATE` | Prefix used to name AWS resources for Fargate launch type integration tests | -| `AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE` | Prefix used to name AWS resources for Fargate launch type integration tests that use CodeDeploy | +| `AWS_RESOURCE_NAME_PREFIX_EC2` | Prefix used to name AWS resources for EC2 launch type integration tests. Set to `ecs-orb-ec2-1`. | +| `AWS_RESOURCE_NAME_PREFIX_FARGATE` | Prefix used to name AWS resources for Fargate launch type integration tests. Set to `ecs-orb-fg-1`. | +| `AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE` | Prefix used to name AWS resources for Fargate launch type integration tests that use CodeDeploy. Set to `ecs-orb-cdfg-1`. | | `SKIP_TEST_ENV_CREATION` | Whether to skip test env setup | | `SKIP_TEST_ENV_TEARDOWN` | Whether to skip test env teardown | +## Setting up / tearing down test infra locally + +You can also set up the same test infrastructure set up by the build pipeline, +by running terraform locally. + +This is also useful when you need to tear down infra manually after the pipeline failed. (For the ec2 and fargate tests, you can also tear down the infrastructure by going to the CloudFormation page on the AWS console and deleting the stacks prefixed with `ecs-orb`) + +Set up AWS credentials and `AWS_DEFAULT_REGION`: + +``` +AWS_ACCESS_KEY_ID=... +AWS_SECRET_ACCESS_KEY=... +AWS_ACCOUNT_ID=... +AWS_DEFAULT_REGION=us-east-1 +``` + +Then set `AWS_RESOURCE_PREFIX` to the correct value: + +*For EC2 tests* + +``` +AWS_RESOURCE_PREFIX=ecs-orb-ec2-1 +cd tests/terraform_setup/ec2 +``` + +*For Fargate tests* + +``` +AWS_RESOURCE_PREFIX=ecs-orb-fg-1 +cd tests/terraform_setup/fargate +``` + +*For CodeDeploy tests* + +``` +AWS_RESOURCE_PREFIX=ecs-orb-cdfg-1 +cd tests/terraform_setup/fargate_codedeploy +``` + +### Infra setup/teardown steps (for all) + +``` +terraform apply \ + -var "aws_access_key=${AWS_ACCESS_KEY_ID}" \ + -var "aws_secret_key=${AWS_SECRET_ACCESS_KEY}" \ + -var "aws_region=${AWS_DEFAULT_REGION}" \ + -var "aws_account_id=${AWS_ACCOUNT_ID}" \ + -var "aws_resource_prefix=${AWS_RESOURCE_PREFIX}" +``` + +``` +terraform destroy \ + -var "aws_access_key=${AWS_ACCESS_KEY_ID}" \ + -var "aws_secret_key=${AWS_SECRET_ACCESS_KEY}" \ + -var "aws_region=${AWS_DEFAULT_REGION}" \ + -var "aws_account_id=${AWS_ACCOUNT_ID}" \ + -var "aws_resource_prefix=${AWS_RESOURCE_PREFIX}" +``` + ### Required Context and Context Environment Variables The `orb-publishing` context is referenced in the build. In particular, the following [context environment variables](https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-context) must be set in the `orb-publishing` context, before the project can be built successfully. From 9c6c73fa9019e74173706571ff1fe8439bd11a4c Mon Sep 17 00:00:00 2001 From: Stella Lok Date: Thu, 4 Jun 2020 20:56:23 +0800 Subject: [PATCH 7/8] fix test --- .circleci/config.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2395fb11..371f6583 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -635,14 +635,10 @@ workflows: 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: false + skip-task-definition-registration: true verify-revision-is-deployed: true max-poll-attempts: 40 poll-interval: 10 - 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: codedeploy_fargate_test-update-service-job From d4c06d61dcb6fa65df015912426855a3a7c1ef55 Mon Sep 17 00:00:00 2001 From: Stella Lok Date: Thu, 4 Jun 2020 21:25:16 +0800 Subject: [PATCH 8/8] undo unnecessary deletion --- src/orb.yml.hbs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/orb.yml.hbs b/src/orb.yml.hbs index 1fbc39d4..3eed55d7 100644 --- a/src/orb.yml.hbs +++ b/src/orb.yml.hbs @@ -962,6 +962,7 @@ commands: - run: name: Update service with registered task definition command: | + set -o noglob DEPLOYMENT_CONTROLLER="$(echo << parameters.deployment-controller >>)" if [ "${DEPLOYMENT_CONTROLLER}" = "CODE_DEPLOY" ]; then