From 2668e63ec4515c36952bcd42ec8825709c9984e3 Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Tue, 3 Dec 2024 15:10:02 -0500 Subject: [PATCH 01/28] Add functionality to create service if not created with ECS deployment --- .circleci/test-deploy.yml | 34 +++++------ src/commands/update_service.yml | 68 +++++++++++++++++++++ src/jobs/deploy_service_update.yml | 69 ++++++++++++++++++++++ src/scripts/update_service_via_task_def.sh | 51 ++++++++++++---- 4 files changed, 194 insertions(+), 28 deletions(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index f41ca1a..e420b6c 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -527,13 +527,13 @@ workflows: # ################# # # EC2 # ################# - - tear-down-test-env: - name: ec2_tear-down-test-env-initial - filters: *filters - aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_EC2} - terraform-config-dir: "tests/terraform_setup/ec2" - context: [CPE-OIDC] - role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + # - tear-down-test-env: + # name: ec2_tear-down-test-env-initial + # filters: *filters + # aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_EC2} + # terraform-config-dir: "tests/terraform_setup/ec2" + # context: [CPE-OIDC] + # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - build-test-app: name: ec2_build-test-app docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com" @@ -626,16 +626,16 @@ workflows: cluster: "${AWS_RESOURCE_NAME_PREFIX_EC2}-cluster" profile: "ECS_TEST_PROFILE" test-asterisk-expansion: true - - tear-down-test-env: - name: ec2_tear-down-test-env - filters: *filters - requires: - - ec2_test-update_service-job - - ec2_tear-down-run_task-test - aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_EC2} - terraform-config-dir: "tests/terraform_setup/ec2" - context: [CPE-OIDC] - role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + # - tear-down-test-env: + # name: ec2_tear-down-test-env + # filters: *filters + # requires: + # - ec2_test-update_service-job + # - ec2_tear-down-run_task-test + # aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_EC2} + # terraform-config-dir: "tests/terraform_setup/ec2" + # context: [CPE-OIDC] + # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" # ################ # FargateSpot # ################ diff --git a/src/commands/update_service.yml b/src/commands/update_service.yml index f8ea1b2..7a3e555 100644 --- a/src/commands/update_service.yml +++ b/src/commands/update_service.yml @@ -188,6 +188,66 @@ parameters: If not specified, the value configured in the deployment group is used as the default. type: string default: '' + create_service: + type: boolean + description: | + Create the service if it does not exist already. + Only works with ECS deployment controller. + Default false. + default: false + desired_count: + description: | + The desired number of tasks to run. If empty it would keep the existing count. + Only works with ECS deployment controller. + Default to empty. + default: "" + type: string + subnets: + description: | + Comma separated list of subnet ids for the service when it needs to be created, e.g. "subnet-00000000,subnet-1111111" + Only works with ECS deployment controller. + Default to empty. + default: "" + type: string + security_groups: + description: | + Comma separated list of security group ids for the service when it needs to be created, e.g. "sg-00000000,sg-1111111" + Only works with ECS deployment controller. + Default to empty. + default: "" + type: string + public_ip: + description: | + Whether the task's elastic network interface receives a public IP address when the service needs to be created. + Only works with ECS deployment controller. + The default value is DISABLED. + default: DISABLED + type: + enum: + - ENABLED + - DISABLED + target_group: + description: | + The full ARN of the Elastic Load Balancing target group or groups associated with a service when it needs to be created. + Only works with ECS deployment controller. + Default to empty. + default: "" + type: string + container_name: + description: | + The name of the container to associate with the load balancer when the service needs to be created. + Only works with ECS deployment controller. + Default to empty. + default: "" + type: string + container_port: + description: | + The port on the container to associate with the load balancer when the service needs to be created. + This port must correspond to a containerPort in the task definition the tasks in the service are using. + Only works with ECS deployment controller. + Default to empty. + default: "" + type: string steps: - unless: @@ -267,6 +327,14 @@ steps: ORB_AWS_REGION: << parameters.region >> ORB_STR_PROFILE_NAME: <> ORB_BOOL_ENABLE_CIRCUIT_BREAKER: <> + ORB_AWS_DESIRED_COUNT: <> + ORB_AWS_CREATE_SERVICE: <> + ORB_STR_SUBNETS: <> + ORB_STR_SECURITY_GROUPS: <> + ORB_PUBLIC_IP: <> + ORB_STR_TARGET_GROUP: <> + ORB_STR_CONTAINER_NAME: <> + ORB_CONTAINER_PORT: <> - when: condition: diff --git a/src/jobs/deploy_service_update.yml b/src/jobs/deploy_service_update.yml index 7c5832c..70cbe73 100644 --- a/src/jobs/deploy_service_update.yml +++ b/src/jobs/deploy_service_update.yml @@ -226,6 +226,67 @@ parameters: description: The executor to use for this job. By default, this will use the "default" executor provided by this orb. type: executor default: default + create_service: + type: boolean + description: | + Create the service if it does not exist already. + Only works with ECS deployment controller. + Default false. + default: false + desired_count: + description: | + The desired number of tasks to run. If empty it would keep the existing count. + Only works with ECS deployment controller. + Default to empty. + default: "" + type: string + subnets: + description: | + Comma separated list of subnet ids for the service when it needs to be created, e.g. "subnet-00000000,subnet-1111111" + Only works with ECS deployment controller. + Default to empty. + default: "" + type: string + security_groups: + description: | + Comma separated list of security group ids for the service when it needs to be created, e.g. "sg-00000000,sg-1111111" + Only works with ECS deployment controller. + Default to empty. + default: "" + type: string + public_ip: + description: | + Whether the task's elastic network interface receives a public IP address when the service needs to be created. + Only works with ECS deployment controller. + The default value is DISABLED. + default: DISABLED + type: + enum: + - ENABLED + - DISABLED + target_group: + description: | + The full ARN of the Elastic Load Balancing target group or groups associated with a service when it needs to be created. + Only works with ECS deployment controller. + Default to empty. + default: "" + type: string + container_name: + description: | + The name of the container to associate with the load balancer when the service needs to be created. + Only works with ECS deployment controller. + Default to empty. + default: "" + type: string + container_port: + description: | + The port on the container to associate with the load balancer when the service needs to be created. + This port must correspond to a containerPort in the task definition the tasks in the service are using. + Only works with ECS deployment controller. + Default to empty. + default: "" + type: string + executor: << parameters.executor >> steps: - steps: << parameters.auth >> @@ -257,3 +318,11 @@ steps: codedeploy_capacity_provider_weight: <> codedeploy_capacity_provider_base: <> deployment_config_name: <> + desired_count: <> + create_service: <> + subnets: <> + security_groups: <> + public_ip: <> + target_group: <> + container_name: <> + container_port: <> diff --git a/src/scripts/update_service_via_task_def.sh b/src/scripts/update_service_via_task_def.sh index 8f7eb3f..00138ba 100644 --- a/src/scripts/update_service_via_task_def.sh +++ b/src/scripts/update_service_via_task_def.sh @@ -8,11 +8,20 @@ ORB_STR_SERVICE_NAME="$(circleci env subst "$ORB_STR_SERVICE_NAME")" ORB_STR_PROFILE_NAME="$(circleci env subst "$ORB_STR_PROFILE_NAME")" ORB_AWS_REGION="$(circleci env subst "$ORB_AWS_REGION")" +SERVICE_EXISTS=$(aws ecs describe-services \ + --profile "${ORB_STR_PROFILE_NAME}" \ + --cluster "$ORB_STR_CLUSTER_NAME" \ + --services "${ORB_STR_SERVICE_NAME}" \ + --query "services[?serviceName=='$ORB_STR_SERVICE_NAME'].serviceName" \ + --region "${ORB_AWS_REGION}" \ + --output text +) +echo "$SERVICE_EXISTS" if [ -z "${ORB_STR_SERVICE_NAME}" ]; then ORB_STR_SERVICE_NAME="$ORB_STR_FAMILY" fi -if [ "$ORB_BOOL_FORCE_NEW_DEPLOY" == "1" ]; then +if [ "$ORB_BOOL_FORCE_NEW_DEPLOY" == "1" ] && [ -n "$SERVICE_EXISTS" ]; then set -- "$@" --force-new-deployment fi @@ -20,13 +29,33 @@ if [ "$ORB_BOOL_ENABLE_CIRCUIT_BREAKER" == "1" ]; then set -- "$@" --deployment-configuration "deploymentCircuitBreaker={enable=true,rollback=true}" fi -DEPLOYED_REVISION=$(aws ecs update-service \ - --profile "${ORB_STR_PROFILE_NAME}" \ - --cluster "$ORB_STR_CLUSTER_NAME" \ - --service "${ORB_STR_SERVICE_NAME}" \ - --task-definition "${CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN}" \ - --output text \ - --region "${ORB_AWS_REGION}" \ - --query service.taskDefinition \ - "$@") -echo "export CCI_ORB_AWS_ECS_DEPLOYED_REVISION='${DEPLOYED_REVISION}'" >> "$BASH_ENV" +if [ -n "$ORB_AWS_DESIRED_COUNT" ]; then + set -- "$@" --desired-count "$ORB_AWS_DESIRED_COUNT" +fi + +if [ -z "$SERVICE_EXISTS" ]; then + echo "The service doesn't exist" + if [ "$ORB_AWS_CREATE_SERVICE" = 1 ]; then + NEW_SERVICE=$(aws ecs create-service \ + --cluster "$ORB_STR_CLUSTER_NAME" \ + --region "${ORB_AWS_REGION}" \ + --profile "${ORB_STR_PROFILE_NAME}" \ + --service-name "${ORB_STR_SERVICE_NAME}" \ + --task-definition "${CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN}" \ + --network-configuration "awsvpcConfiguration={subnets=[$ORB_STR_SUBNETS],securityGroups=[$ORB_STR_SECURITY_GROUPS],assignPublicIp=$ORB_PUBLIC_IP}" \ + --load-balancers "targetGroupArn=$ORB_STR_TARGET_GROUP,containerName=$ORB_STR_CONTAINER_NAME,containerPort=$ORB_CONTAINER_PORT" \ + "$@") + echo "$NEW_SERVICE" + fi +else + DEPLOYED_REVISION=$(aws ecs update-service \ + --profile "${ORB_STR_PROFILE_NAME}" \ + --cluster "$ORB_STR_CLUSTER_NAME" \ + --service "${ORB_STR_SERVICE_NAME}" \ + --task-definition "${CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN}" \ + --output text \ + --region "${ORB_AWS_REGION}" \ + --query service.taskDefinition \ + "$@") + echo "export CCI_ORB_AWS_ECS_DEPLOYED_REVISION='${DEPLOYED_REVISION}'" >> "$BASH_ENV" +fi \ No newline at end of file From 30a24f7ba037987afcbe7d04a7f18a3d39fe8a46 Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Tue, 3 Dec 2024 15:14:25 -0500 Subject: [PATCH 02/28] Fix syntax errors --- src/commands/update_service.yml | 4 ++-- src/jobs/deploy_service_update.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/commands/update_service.yml b/src/commands/update_service.yml index 7a3e555..91619ce 100644 --- a/src/commands/update_service.yml +++ b/src/commands/update_service.yml @@ -222,7 +222,7 @@ parameters: Only works with ECS deployment controller. The default value is DISABLED. default: DISABLED - type: + type: enum enum: - ENABLED - DISABLED @@ -242,7 +242,7 @@ parameters: type: string container_port: description: | - The port on the container to associate with the load balancer when the service needs to be created. + The port on the container to associate with the load balancer when the service needs to be created. This port must correspond to a containerPort in the task definition the tasks in the service are using. Only works with ECS deployment controller. Default to empty. diff --git a/src/jobs/deploy_service_update.yml b/src/jobs/deploy_service_update.yml index 70cbe73..0078166 100644 --- a/src/jobs/deploy_service_update.yml +++ b/src/jobs/deploy_service_update.yml @@ -260,7 +260,7 @@ parameters: Only works with ECS deployment controller. The default value is DISABLED. default: DISABLED - type: + type: enum enum: - ENABLED - DISABLED @@ -280,7 +280,7 @@ parameters: type: string container_port: description: | - The port on the container to associate with the load balancer when the service needs to be created. + The port on the container to associate with the load balancer when the service needs to be created. This port must correspond to a containerPort in the task definition the tasks in the service are using. Only works with ECS deployment controller. Default to empty. From 141d071321053909fb0fb451afc1f0e2cd8b49a3 Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Tue, 3 Dec 2024 15:19:07 -0500 Subject: [PATCH 03/28] Temporarly remove tear down of ec2 for testgin --- .circleci/test-deploy.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index e420b6c..dce13b0 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -540,8 +540,8 @@ workflows: docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_EC2}:${CIRCLE_SHA1}" context: [CPE-OIDC] filters: *filters - requires: - - ec2_tear-down-test-env-initial + # requires: + # - ec2_tear-down-test-env-initial - set-up-test-env: name: ec2_set-up-test-env filters: *filters @@ -766,7 +766,7 @@ workflows: pub_type: production enable_pr_comment: true context: orb-publisher - 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] + requires: [orb-tools/pack, fargate_tear-down-test-env, codedeploy_fargate_tear-down-test-env, integration-test-ecs-cli-install] filters: *release-filters commands: wait-for-codedeploy-deployment: From a487a80763aa5c5658df29dd10ea22a03a91944d Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Tue, 3 Dec 2024 15:53:04 -0500 Subject: [PATCH 04/28] Add test --- .circleci/test-deploy.yml | 199 ++++++++++++++++++++------------------ 1 file changed, 107 insertions(+), 92 deletions(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index dce13b0..9369422 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -527,6 +527,21 @@ workflows: # ################# # # EC2 # ################# + - aws-ecs/deploy_service_update: + filters: *filters + auth: + - aws-cli/setup: + profile_name: profile-create + cluster: ecs-orb-ec2-1-cluster + task_definition: "ecs-orb-ec2-1-family" + service_name: test-create + subnets: subnet-0ac33b77a1409cab5,subnet-06ab605c9f6211389 + security_groups: sg-01476d3bddd6779e7 + desired_count: 2 + target_group: arn:aws:elasticloadbalancing:us-west-2:122211685980:targetgroup/ecs-orb-ec2-1-service/5cfc7471d907d25d + container_name: ecs-orb-ec2-1-service + container_port: 80 + profile: profile-create # - tear-down-test-env: # name: ec2_tear-down-test-env-initial # filters: *filters @@ -534,98 +549,98 @@ workflows: # terraform-config-dir: "tests/terraform_setup/ec2" # context: [CPE-OIDC] # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - - build-test-app: - name: ec2_build-test-app - docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com" - docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_EC2}:${CIRCLE_SHA1}" - context: [CPE-OIDC] - filters: *filters - # requires: - # - ec2_tear-down-test-env-initial - - set-up-test-env: - name: ec2_set-up-test-env - filters: *filters - requires: - - ec2_build-test-app - aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_EC2} - terraform-config-dir: "tests/terraform_setup/ec2" - context: [CPE-OIDC] - role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - - set-up-run_task-test: - name: ec2_set-up-run_task-test - filters: *filters - requires: - - ec2_set-up-test-env - family_name: "${AWS_RESOURCE_NAME_PREFIX_EC2}-sleep360" - context: [CPE-OIDC] - role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - - aws-ecs/run_task: - name: ec2_run_task-test - auth: - - aws-cli/setup: - role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - filters: *filters - requires: - - ec2_set-up-run_task-test - cluster: "${AWS_RESOURCE_NAME_PREFIX_EC2}-cluster" - 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-OIDC] - - tear-down-run_task-test: - name: ec2_tear-down-run_task-test - filters: *filters - requires: - - ec2_run_task-test - family_name: ${AWS_RESOURCE_NAME_PREFIX_EC2}-sleep360 - context: [CPE-OIDC] - role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - - test-service-update: - name: ec2_test-update_service-command - filters: *filters - requires: - - ec2_set-up-test-env - aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_EC2} - family_name: "${AWS_RESOURCE_NAME_PREFIX_EC2}-family" - service_name: "${AWS_RESOURCE_NAME_PREFIX_EC2}-service" - docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com" - secret_arn: "arn:aws:ssm:${AWS_DEFAULT_REGION}:${AWS_ACCOUNT_ID}:parameter/TestParameterUpdate" - docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_EC2}:${CIRCLE_SHA1}" - context: [CPE-OIDC] - role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - - test-task_definition-update: - name: ec2_test-task_definition-update - family_name: "${AWS_RESOURCE_NAME_PREFIX_EC2}-family" - context: [CPE-OIDC] - role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - filters: *filters - requires: - - ec2_test-update_service-command - - aws-ecs/deploy_service_update: - name: ec2_test-update_service-job - auth: - - aws-cli/setup: - role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - profile_name: "ECS_TEST_PROFILE" - profile_name: "ECS_TEST_PROFILE" - context: [CPE-OIDC] - filters: *filters - requires: - - ec2_test-task_definition-update - 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)' - verify_revision_is_deployed: true - fail_on_verification_timeout: false - post-steps: - - test-deployment: - service_name: "${AWS_RESOURCE_NAME_PREFIX_EC2}-service" - cluster: "${AWS_RESOURCE_NAME_PREFIX_EC2}-cluster" - profile: "ECS_TEST_PROFILE" - test-asterisk-expansion: true + # - build-test-app: + # name: ec2_build-test-app + # docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com" + # docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_EC2}:${CIRCLE_SHA1}" + # context: [CPE-OIDC] + # filters: *filters + # # requires: + # # - ec2_tear-down-test-env-initial + # - set-up-test-env: + # name: ec2_set-up-test-env + # filters: *filters + # requires: + # - ec2_build-test-app + # aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_EC2} + # terraform-config-dir: "tests/terraform_setup/ec2" + # context: [CPE-OIDC] + # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + # - set-up-run_task-test: + # name: ec2_set-up-run_task-test + # filters: *filters + # requires: + # - ec2_set-up-test-env + # family_name: "${AWS_RESOURCE_NAME_PREFIX_EC2}-sleep360" + # context: [CPE-OIDC] + # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + # - aws-ecs/run_task: + # name: ec2_run_task-test + # auth: + # - aws-cli/setup: + # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + # filters: *filters + # requires: + # - ec2_set-up-run_task-test + # cluster: "${AWS_RESOURCE_NAME_PREFIX_EC2}-cluster" + # 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-OIDC] + # - tear-down-run_task-test: + # name: ec2_tear-down-run_task-test + # filters: *filters + # requires: + # - ec2_run_task-test + # family_name: ${AWS_RESOURCE_NAME_PREFIX_EC2}-sleep360 + # context: [CPE-OIDC] + # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + # - test-service-update: + # name: ec2_test-update_service-command + # filters: *filters + # requires: + # - ec2_set-up-test-env + # aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_EC2} + # family_name: "${AWS_RESOURCE_NAME_PREFIX_EC2}-family" + # service_name: "${AWS_RESOURCE_NAME_PREFIX_EC2}-service" + # docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com" + # secret_arn: "arn:aws:ssm:${AWS_DEFAULT_REGION}:${AWS_ACCOUNT_ID}:parameter/TestParameterUpdate" + # docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_EC2}:${CIRCLE_SHA1}" + # context: [CPE-OIDC] + # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + # - test-task_definition-update: + # name: ec2_test-task_definition-update + # family_name: "${AWS_RESOURCE_NAME_PREFIX_EC2}-family" + # context: [CPE-OIDC] + # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + # filters: *filters + # requires: + # - ec2_test-update_service-command + # - aws-ecs/deploy_service_update: + # name: ec2_test-update_service-job + # auth: + # - aws-cli/setup: + # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + # profile_name: "ECS_TEST_PROFILE" + # profile_name: "ECS_TEST_PROFILE" + # context: [CPE-OIDC] + # filters: *filters + # requires: + # - ec2_test-task_definition-update + # 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)' + # verify_revision_is_deployed: true + # fail_on_verification_timeout: false + # post-steps: + # - test-deployment: + # service_name: "${AWS_RESOURCE_NAME_PREFIX_EC2}-service" + # cluster: "${AWS_RESOURCE_NAME_PREFIX_EC2}-cluster" + # profile: "ECS_TEST_PROFILE" + # test-asterisk-expansion: true # - tear-down-test-env: # name: ec2_tear-down-test-env # filters: *filters From 7b8841d9482494b3dab9b0fe832906a0ebee9fdb Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Tue, 3 Dec 2024 15:54:51 -0500 Subject: [PATCH 05/28] Fix test --- .circleci/test-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 9369422..e633fc3 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -540,7 +540,7 @@ workflows: desired_count: 2 target_group: arn:aws:elasticloadbalancing:us-west-2:122211685980:targetgroup/ecs-orb-ec2-1-service/5cfc7471d907d25d container_name: ecs-orb-ec2-1-service - container_port: 80 + container_port: "80" profile: profile-create # - tear-down-test-env: # name: ec2_tear-down-test-env-initial From d3a5aa9a7fd4143f37c8efc506c89881fce0c0da Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Tue, 3 Dec 2024 15:55:19 -0500 Subject: [PATCH 06/28] fix test --- .circleci/test-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index e633fc3..337eed7 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -537,7 +537,7 @@ workflows: service_name: test-create subnets: subnet-0ac33b77a1409cab5,subnet-06ab605c9f6211389 security_groups: sg-01476d3bddd6779e7 - desired_count: 2 + desired_count: "2" target_group: arn:aws:elasticloadbalancing:us-west-2:122211685980:targetgroup/ecs-orb-ec2-1-service/5cfc7471d907d25d container_name: ecs-orb-ec2-1-service container_port: "80" From c186c4e5bb11fc5192661669abd61cacc1fdbef7 Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Tue, 3 Dec 2024 16:01:59 -0500 Subject: [PATCH 07/28] fix test --- .circleci/test-deploy.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 337eed7..743ad14 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -532,8 +532,9 @@ workflows: auth: - aws-cli/setup: profile_name: profile-create + family: ecs-orb-ec2-1-family cluster: ecs-orb-ec2-1-cluster - task_definition: "ecs-orb-ec2-1-family" + skip_task_definition_registration: true service_name: test-create subnets: subnet-0ac33b77a1409cab5,subnet-06ab605c9f6211389 security_groups: sg-01476d3bddd6779e7 From 97c6e7586c4a1e9333359256b413befbd62fb182 Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Tue, 3 Dec 2024 16:12:38 -0500 Subject: [PATCH 08/28] Fix tests --- .circleci/test-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 743ad14..4cd3f2b 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -542,7 +542,7 @@ workflows: target_group: arn:aws:elasticloadbalancing:us-west-2:122211685980:targetgroup/ecs-orb-ec2-1-service/5cfc7471d907d25d container_name: ecs-orb-ec2-1-service container_port: "80" - profile: profile-create + profile_name: profile-create # - tear-down-test-env: # name: ec2_tear-down-test-env-initial # filters: *filters From 07598331b6dd7da9c00a2857df739da0569295f0 Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Tue, 3 Dec 2024 16:17:44 -0500 Subject: [PATCH 09/28] Update test --- .circleci/test-deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 4cd3f2b..6b52549 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -542,6 +542,7 @@ workflows: target_group: arn:aws:elasticloadbalancing:us-west-2:122211685980:targetgroup/ecs-orb-ec2-1-service/5cfc7471d907d25d container_name: ecs-orb-ec2-1-service container_port: "80" + region: us-west-2 profile_name: profile-create # - tear-down-test-env: # name: ec2_tear-down-test-env-initial From fe5fa2d6149f6447075cbe52e9beb2b01c24e49c Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Tue, 3 Dec 2024 16:25:57 -0500 Subject: [PATCH 10/28] Update test auth --- .circleci/test-deploy.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 6b52549..b203f32 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -531,7 +531,8 @@ workflows: filters: *filters auth: - aws-cli/setup: - profile_name: profile-create + profile_name: profile-create + role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" family: ecs-orb-ec2-1-family cluster: ecs-orb-ec2-1-cluster skip_task_definition_registration: true From 843052239704c9d597b919833865a569099eb9a7 Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Tue, 3 Dec 2024 16:28:03 -0500 Subject: [PATCH 11/28] Update test --- .circleci/test-deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index b203f32..57c3580 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -535,6 +535,7 @@ workflows: role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" family: ecs-orb-ec2-1-family cluster: ecs-orb-ec2-1-cluster + create_service: true skip_task_definition_registration: true service_name: test-create subnets: subnet-0ac33b77a1409cab5,subnet-06ab605c9f6211389 From f513da5a53e4b2f4018ad789b868f9977d6818e0 Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Tue, 3 Dec 2024 16:53:39 -0500 Subject: [PATCH 12/28] Update command --- src/scripts/update_service_via_task_def.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/update_service_via_task_def.sh b/src/scripts/update_service_via_task_def.sh index 00138ba..3456b34 100644 --- a/src/scripts/update_service_via_task_def.sh +++ b/src/scripts/update_service_via_task_def.sh @@ -42,10 +42,10 @@ if [ -z "$SERVICE_EXISTS" ]; then --profile "${ORB_STR_PROFILE_NAME}" \ --service-name "${ORB_STR_SERVICE_NAME}" \ --task-definition "${CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN}" \ - --network-configuration "awsvpcConfiguration={subnets=[$ORB_STR_SUBNETS],securityGroups=[$ORB_STR_SECURITY_GROUPS],assignPublicIp=$ORB_PUBLIC_IP}" \ --load-balancers "targetGroupArn=$ORB_STR_TARGET_GROUP,containerName=$ORB_STR_CONTAINER_NAME,containerPort=$ORB_CONTAINER_PORT" \ "$@") echo "$NEW_SERVICE" + # --network-configuration "awsvpcConfiguration={subnets=[$ORB_STR_SUBNETS],securityGroups=[$ORB_STR_SECURITY_GROUPS],assignPublicIp=$ORB_PUBLIC_IP}" \ fi else DEPLOYED_REVISION=$(aws ecs update-service \ From d8b08d8e3728189cf1554b09466bcb70710fecbc Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Wed, 4 Dec 2024 09:26:45 -0500 Subject: [PATCH 13/28] Update tests to make them more reliable --- .circleci/test-deploy.yml | 239 +++++++++--------- src/scripts/update_service_via_task_def.sh | 10 +- .../public-service.yml | 6 + tests/terraform_setup/ec2/terraform.tf | 4 + 4 files changed, 143 insertions(+), 116 deletions(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 57c3580..43f6464 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -133,6 +133,9 @@ jobs: - docker-images set-up-test-env: parameters: + export_arn: + type: boolean + default: false terraform-image: type: string default: "hashicorp/terraform:1.4.0" @@ -191,6 +194,11 @@ jobs: cd << parameters.terraform-config-dir >> terraform apply -input=false -auto-approve tfplan set +x + - when: + condition: <> + steps: + run: | + echo 'export TARGET_GROUP_ARN=$(terraform output -raw target_group_arn)' >> $BASH_ENV test-service-update: docker: - image: cimg/python:3.10.4 @@ -439,7 +447,7 @@ workflows: aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_FARGATE} terraform-config-dir: "tests/terraform_setup/fargate" context: [CPE-OIDC] - role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - build-test-app: name: fargate_build-test-app docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com" @@ -527,8 +535,36 @@ workflows: # ################# # # EC2 # ################# + - tear-down-test-env: + name: ec2_tear-down-test-env-initial + filters: *filters + aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_EC2} + terraform-config-dir: "tests/terraform_setup/ec2" + context: [CPE-OIDC] + role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + - build-test-app: + name: ec2_build-test-app + docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com" + docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_EC2}:${CIRCLE_SHA1}" + context: [CPE-OIDC] + filters: *filters + requires: + - ec2_tear-down-test-env-initial + - set-up-test-env: + name: ec2_set-up-test-env + filters: *filters + requires: + - ec2_build-test-app + aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_EC2} + terraform-config-dir: "tests/terraform_setup/ec2" + context: [CPE-OIDC] + role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + export_arn: true - aws-ecs/deploy_service_update: + name: ec2_create_service filters: *filters + requires: + - ec2_set-up-test-env auth: - aws-cli/setup: profile_name: profile-create @@ -538,123 +574,98 @@ workflows: create_service: true skip_task_definition_registration: true service_name: test-create - subnets: subnet-0ac33b77a1409cab5,subnet-06ab605c9f6211389 - security_groups: sg-01476d3bddd6779e7 desired_count: "2" - target_group: arn:aws:elasticloadbalancing:us-west-2:122211685980:targetgroup/ecs-orb-ec2-1-service/5cfc7471d907d25d + target_group: $TARGET_GROUP_ARN container_name: ecs-orb-ec2-1-service container_port: "80" region: us-west-2 profile_name: profile-create - # - tear-down-test-env: - # name: ec2_tear-down-test-env-initial - # filters: *filters - # aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_EC2} - # terraform-config-dir: "tests/terraform_setup/ec2" - # context: [CPE-OIDC] - # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - # - build-test-app: - # name: ec2_build-test-app - # docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com" - # docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_EC2}:${CIRCLE_SHA1}" - # context: [CPE-OIDC] - # filters: *filters - # # requires: - # # - ec2_tear-down-test-env-initial - # - set-up-test-env: - # name: ec2_set-up-test-env - # filters: *filters - # requires: - # - ec2_build-test-app - # aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_EC2} - # terraform-config-dir: "tests/terraform_setup/ec2" - # context: [CPE-OIDC] - # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - # - set-up-run_task-test: - # name: ec2_set-up-run_task-test - # filters: *filters - # requires: - # - ec2_set-up-test-env - # family_name: "${AWS_RESOURCE_NAME_PREFIX_EC2}-sleep360" - # context: [CPE-OIDC] - # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - # - aws-ecs/run_task: - # name: ec2_run_task-test - # auth: - # - aws-cli/setup: - # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - # filters: *filters - # requires: - # - ec2_set-up-run_task-test - # cluster: "${AWS_RESOURCE_NAME_PREFIX_EC2}-cluster" - # 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-OIDC] - # - tear-down-run_task-test: - # name: ec2_tear-down-run_task-test - # filters: *filters - # requires: - # - ec2_run_task-test - # family_name: ${AWS_RESOURCE_NAME_PREFIX_EC2}-sleep360 - # context: [CPE-OIDC] - # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - # - test-service-update: - # name: ec2_test-update_service-command - # filters: *filters - # requires: - # - ec2_set-up-test-env - # aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_EC2} - # family_name: "${AWS_RESOURCE_NAME_PREFIX_EC2}-family" - # service_name: "${AWS_RESOURCE_NAME_PREFIX_EC2}-service" - # docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com" - # secret_arn: "arn:aws:ssm:${AWS_DEFAULT_REGION}:${AWS_ACCOUNT_ID}:parameter/TestParameterUpdate" - # docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_EC2}:${CIRCLE_SHA1}" - # context: [CPE-OIDC] - # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - # - test-task_definition-update: - # name: ec2_test-task_definition-update - # family_name: "${AWS_RESOURCE_NAME_PREFIX_EC2}-family" - # context: [CPE-OIDC] - # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - # filters: *filters - # requires: - # - ec2_test-update_service-command - # - aws-ecs/deploy_service_update: - # name: ec2_test-update_service-job - # auth: - # - aws-cli/setup: - # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - # profile_name: "ECS_TEST_PROFILE" - # profile_name: "ECS_TEST_PROFILE" - # context: [CPE-OIDC] - # filters: *filters - # requires: - # - ec2_test-task_definition-update - # 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)' - # verify_revision_is_deployed: true - # fail_on_verification_timeout: false - # post-steps: - # - test-deployment: - # service_name: "${AWS_RESOURCE_NAME_PREFIX_EC2}-service" - # cluster: "${AWS_RESOURCE_NAME_PREFIX_EC2}-cluster" - # profile: "ECS_TEST_PROFILE" - # test-asterisk-expansion: true - # - tear-down-test-env: - # name: ec2_tear-down-test-env - # filters: *filters - # requires: - # - ec2_test-update_service-job - # - ec2_tear-down-run_task-test - # aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_EC2} - # terraform-config-dir: "tests/terraform_setup/ec2" - # context: [CPE-OIDC] - # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + - set-up-run_task-test: + name: ec2_set-up-run_task-test + filters: *filters + requires: + - ec2_set-up-test-env + family_name: "${AWS_RESOURCE_NAME_PREFIX_EC2}-sleep360" + context: [CPE-OIDC] + role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + - aws-ecs/run_task: + name: ec2_run_task-test + auth: + - aws-cli/setup: + role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + filters: *filters + requires: + - ec2_set-up-run_task-test + cluster: "${AWS_RESOURCE_NAME_PREFIX_EC2}-cluster" + 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-OIDC] + - tear-down-run_task-test: + name: ec2_tear-down-run_task-test + filters: *filters + requires: + - ec2_run_task-test + - ec2_create_service + family_name: ${AWS_RESOURCE_NAME_PREFIX_EC2}-sleep360 + context: [CPE-OIDC] + role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + - test-service-update: + name: ec2_test-update_service-command + filters: *filters + requires: + - ec2_set-up-test-env + aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_EC2} + family_name: "${AWS_RESOURCE_NAME_PREFIX_EC2}-family" + service_name: "${AWS_RESOURCE_NAME_PREFIX_EC2}-service" + docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com" + secret_arn: "arn:aws:ssm:${AWS_DEFAULT_REGION}:${AWS_ACCOUNT_ID}:parameter/TestParameterUpdate" + docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_EC2}:${CIRCLE_SHA1}" + context: [CPE-OIDC] + role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + - test-task_definition-update: + name: ec2_test-task_definition-update + family_name: "${AWS_RESOURCE_NAME_PREFIX_EC2}-family" + context: [CPE-OIDC] + role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + filters: *filters + requires: + - ec2_test-update_service-command + - aws-ecs/deploy_service_update: + name: ec2_test-update_service-job + auth: + - aws-cli/setup: + role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + profile_name: "ECS_TEST_PROFILE" + profile_name: "ECS_TEST_PROFILE" + context: [CPE-OIDC] + filters: *filters + requires: + - ec2_test-task_definition-update + 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)' + verify_revision_is_deployed: true + fail_on_verification_timeout: false + post-steps: + - test-deployment: + service_name: "${AWS_RESOURCE_NAME_PREFIX_EC2}-service" + cluster: "${AWS_RESOURCE_NAME_PREFIX_EC2}-cluster" + profile: "ECS_TEST_PROFILE" + test-asterisk-expansion: true + - tear-down-test-env: + name: ec2_tear-down-test-env + filters: *filters + requires: + - ec2_test-update_service-job + - ec2_tear-down-run_task-test + aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_EC2} + terraform-config-dir: "tests/terraform_setup/ec2" + context: [CPE-OIDC] + role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" # ################ # FargateSpot # ################ @@ -785,7 +796,7 @@ workflows: pub_type: production enable_pr_comment: true context: orb-publisher - requires: [orb-tools/pack, fargate_tear-down-test-env, codedeploy_fargate_tear-down-test-env, integration-test-ecs-cli-install] + 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] filters: *release-filters commands: wait-for-codedeploy-deployment: diff --git a/src/scripts/update_service_via_task_def.sh b/src/scripts/update_service_via_task_def.sh index 3456b34..36c4b8a 100644 --- a/src/scripts/update_service_via_task_def.sh +++ b/src/scripts/update_service_via_task_def.sh @@ -7,6 +7,9 @@ ORB_STR_CLUSTER_NAME="$(circleci env subst "$ORB_STR_CLUSTER_NAME")" ORB_STR_SERVICE_NAME="$(circleci env subst "$ORB_STR_SERVICE_NAME")" ORB_STR_PROFILE_NAME="$(circleci env subst "$ORB_STR_PROFILE_NAME")" ORB_AWS_REGION="$(circleci env subst "$ORB_AWS_REGION")" +ORB_STR_SUBNETS="$(circleci env subst "$ORB_STR_SUBNETS")" +ORB_STR_SECURITY_GROUPS="$(circleci env subst "$ORB_STR_SECURITY_GROUPS")" +ORB_STR_TARGET_GROUP="$(circleci env subst "$ORB_STR_TARGET_GROUP")" SERVICE_EXISTS=$(aws ecs describe-services \ --profile "${ORB_STR_PROFILE_NAME}" \ @@ -16,7 +19,7 @@ SERVICE_EXISTS=$(aws ecs describe-services \ --region "${ORB_AWS_REGION}" \ --output text ) -echo "$SERVICE_EXISTS" + if [ -z "${ORB_STR_SERVICE_NAME}" ]; then ORB_STR_SERVICE_NAME="$ORB_STR_FAMILY" fi @@ -33,6 +36,10 @@ if [ -n "$ORB_AWS_DESIRED_COUNT" ]; then set -- "$@" --desired-count "$ORB_AWS_DESIRED_COUNT" fi +if [ -n "$ORB_STR_SUBNETS" ] && [ -n "$ORB_STR_SECURITY_GROUPS" ] && [ -z "$SERVICE_EXISTS" ]; then + set -- "$@" --network-configuration "awsvpcConfiguration={subnets=[$ORB_STR_SUBNETS],securityGroups=[$ORB_STR_SECURITY_GROUPS],assignPublicIp=$ORB_PUBLIC_IP}" +fi + if [ -z "$SERVICE_EXISTS" ]; then echo "The service doesn't exist" if [ "$ORB_AWS_CREATE_SERVICE" = 1 ]; then @@ -45,7 +52,6 @@ if [ -z "$SERVICE_EXISTS" ]; then --load-balancers "targetGroupArn=$ORB_STR_TARGET_GROUP,containerName=$ORB_STR_CONTAINER_NAME,containerPort=$ORB_CONTAINER_PORT" \ "$@") echo "$NEW_SERVICE" - # --network-configuration "awsvpcConfiguration={subnets=[$ORB_STR_SUBNETS],securityGroups=[$ORB_STR_SECURITY_GROUPS],assignPublicIp=$ORB_PUBLIC_IP}" \ fi else DEPLOYED_REVISION=$(aws ecs update-service \ diff --git a/tests/terraform_setup/ec2/cloudformation-templates/public-service.yml b/tests/terraform_setup/ec2/cloudformation-templates/public-service.yml index 0a676ad..321b59b 100644 --- a/tests/terraform_setup/ec2/cloudformation-templates/public-service.yml +++ b/tests/terraform_setup/ec2/cloudformation-templates/public-service.yml @@ -176,3 +176,9 @@ Resources: Fn::ImportValue: !Join [':', [!Ref 'StackName', 'PublicListener']] Priority: !Ref 'Priority' + +Outputs: + TargetGroupArn: + Value: !Ref TargetGroup + Export: + Name: TargetGroupArnExport diff --git a/tests/terraform_setup/ec2/terraform.tf b/tests/terraform_setup/ec2/terraform.tf index dd65dc5..12cb517 100644 --- a/tests/terraform_setup/ec2/terraform.tf +++ b/tests/terraform_setup/ec2/terraform.tf @@ -75,3 +75,7 @@ resource "aws_cloudformation_stack" "ecs_service" { # nginx image when created } } + +output "target_group_arn" { + value = aws_cloudformation_stack.ecs_service.outputs["TargetGroupArn"] +} \ No newline at end of file From 9b4d9a02a0a801557d0cc00fe0184c35c849ba10 Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Wed, 4 Dec 2024 11:08:34 -0500 Subject: [PATCH 14/28] Delete service after creation --- .circleci/test-deploy.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 43f6464..9c9d93a 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -580,6 +580,11 @@ workflows: container_port: "80" region: us-west-2 profile_name: profile-create + post-steps: + - run: + command: | + aws ecs update-service --cluster ecs-orb-ec2-1-cluster --service test-create --desired-count 0 --region us-west-2 --profile profile-create + aws ecs delete-service --cluster ecs-orb-ec2-1-cluster --service test-create --region us-west-2 --profile profile-create --force - set-up-run_task-test: name: ec2_set-up-run_task-test filters: *filters From 3af45f9dfbb714d228d201e1ffc14308689425a9 Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Wed, 4 Dec 2024 12:13:46 -0500 Subject: [PATCH 15/28] Update test structure and fix update_service script --- .circleci/test-deploy.yml | 51 +++++++++++++--------- src/scripts/update_service_via_task_def.sh | 8 ++-- 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 9c9d93a..c8dde85 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -199,6 +199,35 @@ jobs: steps: run: | echo 'export TARGET_GROUP_ARN=$(terraform output -raw target_group_arn)' >> $BASH_ENV + source $BASH_ENV + echo $TARGET_GROUP_ARN + test-service-create: + docker: + - image: hashicorp/terraform:1.4.0 + steps: + - checkout + - aws-cli/setup: + profile_name: profile-create + role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + - run: | + cd tests/terraform_setup/ec2 + terraform init + echo 'export TARGET_GROUP_ARN=$(terraform output -raw target_group_arn)' >> $BASH_ENV + - aws-ecs/update_service: + family: ecs-orb-ec2-1-family + cluster: ecs-orb-ec2-1-cluster + create_service: true + skip_task_definition_registration: true + service_name: test-create + desired_count: "2" + target_group: $TARGET_GROUP_ARN + container_name: ecs-orb-ec2-1-service + container_port: "80" + region: us-west-2 + profile_name: profile-create + - run: | + aws ecs update-service --cluster ecs-orb-ec2-1-cluster --service test-create --desired-count 0 --region us-west-2 --profile profile-create + aws ecs delete-service --cluster ecs-orb-ec2-1-cluster --service test-create --region us-west-2 --profile profile-create --force test-service-update: docker: - image: cimg/python:3.10.4 @@ -560,31 +589,11 @@ workflows: context: [CPE-OIDC] role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" export_arn: true - - aws-ecs/deploy_service_update: + - test-service-create: name: ec2_create_service filters: *filters requires: - ec2_set-up-test-env - auth: - - aws-cli/setup: - profile_name: profile-create - role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - family: ecs-orb-ec2-1-family - cluster: ecs-orb-ec2-1-cluster - create_service: true - skip_task_definition_registration: true - service_name: test-create - desired_count: "2" - target_group: $TARGET_GROUP_ARN - container_name: ecs-orb-ec2-1-service - container_port: "80" - region: us-west-2 - profile_name: profile-create - post-steps: - - run: - command: | - aws ecs update-service --cluster ecs-orb-ec2-1-cluster --service test-create --desired-count 0 --region us-west-2 --profile profile-create - aws ecs delete-service --cluster ecs-orb-ec2-1-cluster --service test-create --region us-west-2 --profile profile-create --force - set-up-run_task-test: name: ec2_set-up-run_task-test filters: *filters diff --git a/src/scripts/update_service_via_task_def.sh b/src/scripts/update_service_via_task_def.sh index 36c4b8a..18f3c19 100644 --- a/src/scripts/update_service_via_task_def.sh +++ b/src/scripts/update_service_via_task_def.sh @@ -11,6 +11,10 @@ ORB_STR_SUBNETS="$(circleci env subst "$ORB_STR_SUBNETS")" ORB_STR_SECURITY_GROUPS="$(circleci env subst "$ORB_STR_SECURITY_GROUPS")" ORB_STR_TARGET_GROUP="$(circleci env subst "$ORB_STR_TARGET_GROUP")" +if [ -z "${ORB_STR_SERVICE_NAME}" ]; then + ORB_STR_SERVICE_NAME="$ORB_STR_FAMILY" +fi + SERVICE_EXISTS=$(aws ecs describe-services \ --profile "${ORB_STR_PROFILE_NAME}" \ --cluster "$ORB_STR_CLUSTER_NAME" \ @@ -20,10 +24,6 @@ SERVICE_EXISTS=$(aws ecs describe-services \ --output text ) -if [ -z "${ORB_STR_SERVICE_NAME}" ]; then - ORB_STR_SERVICE_NAME="$ORB_STR_FAMILY" -fi - if [ "$ORB_BOOL_FORCE_NEW_DEPLOY" == "1" ] && [ -n "$SERVICE_EXISTS" ]; then set -- "$@" --force-new-deployment fi From 255bec2d816bcc0e54b9ab62598216b3a5161bcb Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Wed, 4 Dec 2024 13:56:23 -0500 Subject: [PATCH 16/28] Update profile in test --- .circleci/test-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index c8dde85..26e7f8f 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -211,7 +211,7 @@ jobs: role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - run: | cd tests/terraform_setup/ec2 - terraform init + terraform init -backend-config="profile=profile-create" echo 'export TARGET_GROUP_ARN=$(terraform output -raw target_group_arn)' >> $BASH_ENV - aws-ecs/update_service: family: ecs-orb-ec2-1-family From 3a7b0fb8595c825a946753c3a952b7bacaa2d538 Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Wed, 4 Dec 2024 14:23:53 -0500 Subject: [PATCH 17/28] Add debug to create service --- .circleci/test-deploy.yml | 3 ++- src/scripts/update_service_via_task_def.sh | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 26e7f8f..0727203 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -212,7 +212,8 @@ jobs: - run: | cd tests/terraform_setup/ec2 terraform init -backend-config="profile=profile-create" - echo 'export TARGET_GROUP_ARN=$(terraform output -raw target_group_arn)' >> $BASH_ENV + TG_ARN=$(terraform output -raw target_group_arn) + echo "export TARGET_GROUP_ARN=$TG_ARN" >> $BASH_ENV - aws-ecs/update_service: family: ecs-orb-ec2-1-family cluster: ecs-orb-ec2-1-cluster diff --git a/src/scripts/update_service_via_task_def.sh b/src/scripts/update_service_via_task_def.sh index 18f3c19..760beee 100644 --- a/src/scripts/update_service_via_task_def.sh +++ b/src/scripts/update_service_via_task_def.sh @@ -41,8 +41,10 @@ if [ -n "$ORB_STR_SUBNETS" ] && [ -n "$ORB_STR_SECURITY_GROUPS" ] && [ -z "$SERV fi if [ -z "$SERVICE_EXISTS" ]; then - echo "The service doesn't exist" + echo "The service doesn't exist." if [ "$ORB_AWS_CREATE_SERVICE" = 1 ]; then + echo "Creating it." + set -x NEW_SERVICE=$(aws ecs create-service \ --cluster "$ORB_STR_CLUSTER_NAME" \ --region "${ORB_AWS_REGION}" \ @@ -51,6 +53,7 @@ if [ -z "$SERVICE_EXISTS" ]; then --task-definition "${CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN}" \ --load-balancers "targetGroupArn=$ORB_STR_TARGET_GROUP,containerName=$ORB_STR_CONTAINER_NAME,containerPort=$ORB_CONTAINER_PORT" \ "$@") + set +x echo "$NEW_SERVICE" fi else From 213e14d22159428881a6a4a041a531a1bc12c683 Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Wed, 4 Dec 2024 15:04:13 -0500 Subject: [PATCH 18/28] Add more debug --- .circleci/test-deploy.yml | 12 +----------- src/commands/update_service.yml | 1 + src/scripts/update_service_via_task_def.sh | 2 +- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 0727203..fe603f2 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -133,9 +133,6 @@ jobs: - docker-images set-up-test-env: parameters: - export_arn: - type: boolean - default: false terraform-image: type: string default: "hashicorp/terraform:1.4.0" @@ -194,13 +191,6 @@ jobs: cd << parameters.terraform-config-dir >> terraform apply -input=false -auto-approve tfplan set +x - - when: - condition: <> - steps: - run: | - echo 'export TARGET_GROUP_ARN=$(terraform output -raw target_group_arn)' >> $BASH_ENV - source $BASH_ENV - echo $TARGET_GROUP_ARN test-service-create: docker: - image: hashicorp/terraform:1.4.0 @@ -213,6 +203,7 @@ jobs: cd tests/terraform_setup/ec2 terraform init -backend-config="profile=profile-create" TG_ARN=$(terraform output -raw target_group_arn) + echo $TG_ARN echo "export TARGET_GROUP_ARN=$TG_ARN" >> $BASH_ENV - aws-ecs/update_service: family: ecs-orb-ec2-1-family @@ -589,7 +580,6 @@ workflows: terraform-config-dir: "tests/terraform_setup/ec2" context: [CPE-OIDC] role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - export_arn: true - test-service-create: name: ec2_create_service filters: *filters diff --git a/src/commands/update_service.yml b/src/commands/update_service.yml index 91619ce..7b9ae3d 100644 --- a/src/commands/update_service.yml +++ b/src/commands/update_service.yml @@ -273,6 +273,7 @@ steps: --query 'taskDefinition.taskDefinitionArn' \ --profile << parameters.profile_name >> \ --region << parameters.region >>) + echo $TASK_DEFINITION_ARN echo "export CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN='${TASK_DEFINITION_ARN}'" >> $BASH_ENV - when: condition: << parameters.task_definition_tags >> diff --git a/src/scripts/update_service_via_task_def.sh b/src/scripts/update_service_via_task_def.sh index 760beee..905297c 100644 --- a/src/scripts/update_service_via_task_def.sh +++ b/src/scripts/update_service_via_task_def.sh @@ -1,6 +1,6 @@ #!/bin/bash set -o noglob - +source $BASH_ENV # These variables are evaluated so the config file may contain and pass in environment variables to the parameters. ORB_STR_FAMILY="$(circleci env subst "$ORB_STR_FAMILY")" ORB_STR_CLUSTER_NAME="$(circleci env subst "$ORB_STR_CLUSTER_NAME")" From cd2458f3ba027405c47b79f72c4de9c1960146ee Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Wed, 4 Dec 2024 15:05:09 -0500 Subject: [PATCH 19/28] Fix linter --- src/scripts/update_service_via_task_def.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/update_service_via_task_def.sh b/src/scripts/update_service_via_task_def.sh index 905297c..6a66511 100644 --- a/src/scripts/update_service_via_task_def.sh +++ b/src/scripts/update_service_via_task_def.sh @@ -1,6 +1,6 @@ #!/bin/bash set -o noglob -source $BASH_ENV +source "$BASH_ENV" # These variables are evaluated so the config file may contain and pass in environment variables to the parameters. ORB_STR_FAMILY="$(circleci env subst "$ORB_STR_FAMILY")" ORB_STR_CLUSTER_NAME="$(circleci env subst "$ORB_STR_CLUSTER_NAME")" From 4d2e7bae4be2ac86be9b6fbadd421745940d71be Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Wed, 4 Dec 2024 15:09:03 -0500 Subject: [PATCH 20/28] Ignore healthcheck --- src/scripts/update_service_via_task_def.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/scripts/update_service_via_task_def.sh b/src/scripts/update_service_via_task_def.sh index 6a66511..2981e59 100644 --- a/src/scripts/update_service_via_task_def.sh +++ b/src/scripts/update_service_via_task_def.sh @@ -1,5 +1,6 @@ #!/bin/bash set -o noglob +# shellcheck source=/dev/null source "$BASH_ENV" # These variables are evaluated so the config file may contain and pass in environment variables to the parameters. ORB_STR_FAMILY="$(circleci env subst "$ORB_STR_FAMILY")" From cd837c376e164fcc582b6dfe2fe206b4b6dadb39 Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Wed, 4 Dec 2024 15:33:30 -0500 Subject: [PATCH 21/28] Add more debug --- .circleci/test-deploy.yml | 1 + src/commands/update_service.yml | 2 +- src/scripts/update_service_via_task_def.sh | 3 +-- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index fe603f2..09af921 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -194,6 +194,7 @@ jobs: test-service-create: docker: - image: hashicorp/terraform:1.4.0 + shell: bash -eox pipefail steps: - checkout - aws-cli/setup: diff --git a/src/commands/update_service.yml b/src/commands/update_service.yml index 7b9ae3d..407cccf 100644 --- a/src/commands/update_service.yml +++ b/src/commands/update_service.yml @@ -273,7 +273,7 @@ steps: --query 'taskDefinition.taskDefinitionArn' \ --profile << parameters.profile_name >> \ --region << parameters.region >>) - echo $TASK_DEFINITION_ARN + echo "$TASK_DEFINITION_ARN" echo "export CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN='${TASK_DEFINITION_ARN}'" >> $BASH_ENV - when: condition: << parameters.task_definition_tags >> diff --git a/src/scripts/update_service_via_task_def.sh b/src/scripts/update_service_via_task_def.sh index 2981e59..760beee 100644 --- a/src/scripts/update_service_via_task_def.sh +++ b/src/scripts/update_service_via_task_def.sh @@ -1,7 +1,6 @@ #!/bin/bash set -o noglob -# shellcheck source=/dev/null -source "$BASH_ENV" + # These variables are evaluated so the config file may contain and pass in environment variables to the parameters. ORB_STR_FAMILY="$(circleci env subst "$ORB_STR_FAMILY")" ORB_STR_CLUSTER_NAME="$(circleci env subst "$ORB_STR_CLUSTER_NAME")" From 23fcc1e5910db11693ee0ddee374966154f095b4 Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Wed, 4 Dec 2024 15:39:14 -0500 Subject: [PATCH 22/28] Remove non related tests temp --- .circleci/test-deploy.yml | 434 +++++++++++++++++++------------------- 1 file changed, 217 insertions(+), 217 deletions(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 09af921..0d53a9b 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -463,97 +463,97 @@ workflows: ################# # Fargate ################# - - tear-down-test-env: - name: fargate_tear-down-test-env-initial - filters: *filters - aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_FARGATE} - terraform-config-dir: "tests/terraform_setup/fargate" - context: [CPE-OIDC] - role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - - 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-OIDC] - requires: - - fargate_tear-down-test-env-initial - 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-OIDC] - role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - - 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}" - secret_arn: "arn:aws:ssm:${AWS_DEFAULT_REGION}:${AWS_ACCOUNT_ID}:parameter/TestParameterFargateUpdate" - context: [CPE-OIDC] - role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - - aws-ecs/deploy_service_update: - name: fargate_test-update_service-job - auth: - - aws-cli/setup: - role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - profile_name: "ECS_TEST_PROFILE" - filters: *filters - requires: - - fargate_test-update_service-command - 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-OIDC] - post-steps: - - test-deployment: - profile: "ECS_TEST_PROFILE" - 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 - auth: - - aws-cli/setup: - role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - profile_name: "ECS_TEST_PROFILE" - filters: *filters - requires: - - fargate_test-update_service-job - 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-OIDC] - - 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-OIDC] - role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + # - tear-down-test-env: + # name: fargate_tear-down-test-env-initial + # filters: *filters + # aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_FARGATE} + # terraform-config-dir: "tests/terraform_setup/fargate" + # context: [CPE-OIDC] + # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + # - 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-OIDC] + # requires: + # - fargate_tear-down-test-env-initial + # 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-OIDC] + # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + # - 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}" + # secret_arn: "arn:aws:ssm:${AWS_DEFAULT_REGION}:${AWS_ACCOUNT_ID}:parameter/TestParameterFargateUpdate" + # context: [CPE-OIDC] + # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + # - aws-ecs/deploy_service_update: + # name: fargate_test-update_service-job + # auth: + # - aws-cli/setup: + # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + # profile_name: "ECS_TEST_PROFILE" + # filters: *filters + # requires: + # - fargate_test-update_service-command + # 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-OIDC] + # post-steps: + # - test-deployment: + # profile: "ECS_TEST_PROFILE" + # 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 + # auth: + # - aws-cli/setup: + # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + # profile_name: "ECS_TEST_PROFILE" + # filters: *filters + # requires: + # - fargate_test-update_service-job + # 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-OIDC] + # - 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-OIDC] + # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" # ################# # # EC2 # ################# @@ -675,135 +675,135 @@ workflows: # ################ # FargateSpot # ################ - - test-fargatespot: - context: [CPE-OIDC] - filters: *filters - role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - requires: - - fargate_set-up-test-env + # - test-fargatespot: + # context: [CPE-OIDC] + # filters: *filters + # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + # requires: + # - fargate_set-up-test-env ################# # CodeDeploy ################# - - tear-down-test-env: - name: codedeploy_fargate_tear-down-test-env-initial - terraform-image: "hashicorp/terraform:1.4.0" - aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE} - terraform-config-dir: "tests/terraform_setup/fargate_codedeploy" - context: [CPE-OIDC] - role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - filters: *filters - - build-test-app: - name: codedeploy_fargate_build-test-app - docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com" - docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}:${CIRCLE_SHA1}" - context: [CPE-OIDC] - requires: - - codedeploy_fargate_tear-down-test-env-initial - 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.4.0" - aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE} - terraform-config-dir: "tests/terraform_setup/fargate_codedeploy" - context: [CPE-OIDC] - role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - - 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_REGION}.amazonaws.com" - docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}:${CIRCLE_SHA1}" - role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - skip-service-update: true - context: [CPE-OIDC] - - aws-ecs/deploy_service_update: - name: codedeploy_fargate_test-update_service-job - auth: - - aws-cli/setup: - role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - filters: *filters - requires: - - codedeploy_fargate_test-update_service-command - region: $AWS_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_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: "80" - codedeploy_capacity_provider_name: "FARGATE" - codedeploy_capacity_provider_base: "1" - codedeploy_capacity_provider_weight: "2" - verify_revision_is_deployed: false - context: [CPE-OIDC] - 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 - auth: - - aws-cli/setup: - role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - context: [CPE-OIDC] - filters: *filters - requires: - - codedeploy_fargate_test-update_service-job - region: $AWS_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_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: "80" - 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 - port: "8080" - - 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.4.0" - aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE} - terraform-config-dir: "tests/terraform_setup/fargate_codedeploy" - context: [CPE-OIDC] - role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - filters: *filters - - orb-tools/pack: - filters: *release-filters - - orb-tools/publish: - orb_name: circleci/aws-ecs - vcs_type: << pipeline.project.type >> - pub_type: production - enable_pr_comment: true - context: orb-publisher - 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] - filters: *release-filters + # - tear-down-test-env: + # name: codedeploy_fargate_tear-down-test-env-initial + # terraform-image: "hashicorp/terraform:1.4.0" + # aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE} + # terraform-config-dir: "tests/terraform_setup/fargate_codedeploy" + # context: [CPE-OIDC] + # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + # filters: *filters + # - build-test-app: + # name: codedeploy_fargate_build-test-app + # docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com" + # docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}:${CIRCLE_SHA1}" + # context: [CPE-OIDC] + # requires: + # - codedeploy_fargate_tear-down-test-env-initial + # 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.4.0" + # aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE} + # terraform-config-dir: "tests/terraform_setup/fargate_codedeploy" + # context: [CPE-OIDC] + # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + # - 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_REGION}.amazonaws.com" + # docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}:${CIRCLE_SHA1}" + # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + # skip-service-update: true + # context: [CPE-OIDC] + # - aws-ecs/deploy_service_update: + # name: codedeploy_fargate_test-update_service-job + # auth: + # - aws-cli/setup: + # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + # filters: *filters + # requires: + # - codedeploy_fargate_test-update_service-command + # region: $AWS_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_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: "80" + # codedeploy_capacity_provider_name: "FARGATE" + # codedeploy_capacity_provider_base: "1" + # codedeploy_capacity_provider_weight: "2" + # verify_revision_is_deployed: false + # context: [CPE-OIDC] + # 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 + # auth: + # - aws-cli/setup: + # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + # context: [CPE-OIDC] + # filters: *filters + # requires: + # - codedeploy_fargate_test-update_service-job + # region: $AWS_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_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: "80" + # 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 + # port: "8080" + # - 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.4.0" + # aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE} + # terraform-config-dir: "tests/terraform_setup/fargate_codedeploy" + # context: [CPE-OIDC] + # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + # filters: *filters + # - orb-tools/pack: + # filters: *release-filters + # - orb-tools/publish: + # orb_name: circleci/aws-ecs + # vcs_type: << pipeline.project.type >> + # pub_type: production + # enable_pr_comment: true + # context: orb-publisher + # 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] + # filters: *release-filters commands: wait-for-codedeploy-deployment: description: "Wait for the CodeDeploy deployment to be successful" From 96bbe1b83d346e5e75ac9214eb2dbf71818eab00 Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Wed, 4 Dec 2024 15:56:24 -0500 Subject: [PATCH 23/28] Fix shell --- .circleci/test-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 0d53a9b..56cbb06 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -194,7 +194,7 @@ jobs: test-service-create: docker: - image: hashicorp/terraform:1.4.0 - shell: bash -eox pipefail + shell: sh -eox pipefail steps: - checkout - aws-cli/setup: From ec10dc4604f0c98e4b340ce7bc3e385caf83c7e4 Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Thu, 5 Dec 2024 09:04:45 -0500 Subject: [PATCH 24/28] Manually install terraform --- .circleci/test-deploy.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 56cbb06..339b511 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -4,6 +4,7 @@ orbs: aws-cli: circleci/aws-cli@4.1 jq: circleci/jq@3.0 aws-ecs: {} + terraform: circleci/terraform-orb@3.5.0 filters: &filters tags: only: /.*/ @@ -193,10 +194,11 @@ jobs: set +x test-service-create: docker: - - image: hashicorp/terraform:1.4.0 - shell: sh -eox pipefail + - image: cimg/python:3.10.4 + shell: bash -eox pipefail steps: - checkout + - terraform/install - aws-cli/setup: profile_name: profile-create role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" From 83f773baa192b2c6979f04f4b46a20c7af423ec0 Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Thu, 5 Dec 2024 09:10:06 -0500 Subject: [PATCH 25/28] Fix orb name --- .circleci/test-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 339b511..7973e7f 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -4,7 +4,7 @@ orbs: aws-cli: circleci/aws-cli@4.1 jq: circleci/jq@3.0 aws-ecs: {} - terraform: circleci/terraform-orb@3.5.0 + terraform: circleci/terraform@3.5.0 filters: &filters tags: only: /.*/ From 765cdc0f22bcbf8c57f54c3408fc363768cf135b Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Thu, 5 Dec 2024 09:33:57 -0500 Subject: [PATCH 26/28] Update how task definition is get --- src/commands/update_service.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/update_service.yml b/src/commands/update_service.yml index 407cccf..84d5b32 100644 --- a/src/commands/update_service.yml +++ b/src/commands/update_service.yml @@ -266,7 +266,7 @@ steps: steps: - run: name: Retrieve previous task definition - command: > + command: | TASK_DEFINITION_ARN=$(aws ecs describe-task-definition \ --task-definition << parameters.family >> \ --output text \ @@ -274,7 +274,7 @@ steps: --profile << parameters.profile_name >> \ --region << parameters.region >>) echo "$TASK_DEFINITION_ARN" - echo "export CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN='${TASK_DEFINITION_ARN}'" >> $BASH_ENV + echo "export CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN=$TASK_DEFINITION_ARN" >> $BASH_ENV - when: condition: << parameters.task_definition_tags >> steps: From 9a3b21d98b424c4b52ebc985a543877643490c5c Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Thu, 5 Dec 2024 10:16:02 -0500 Subject: [PATCH 27/28] Restore tests --- .circleci/test-deploy.yml | 438 ++++++++++++++++---------------- src/commands/update_service.yml | 1 - 2 files changed, 219 insertions(+), 220 deletions(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 7973e7f..571cbd8 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -1,7 +1,7 @@ version: 2.1 orbs: - orb-tools: circleci/orb-tools@12.1 - aws-cli: circleci/aws-cli@4.1 + orb-tools: circleci/orb-tools@12.2 + aws-cli: circleci/aws-cli@5.1.1 jq: circleci/jq@3.0 aws-ecs: {} terraform: circleci/terraform@3.5.0 @@ -465,97 +465,97 @@ workflows: ################# # Fargate ################# - # - tear-down-test-env: - # name: fargate_tear-down-test-env-initial - # filters: *filters - # aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_FARGATE} - # terraform-config-dir: "tests/terraform_setup/fargate" - # context: [CPE-OIDC] - # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - # - 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-OIDC] - # requires: - # - fargate_tear-down-test-env-initial - # 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-OIDC] - # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - # - 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}" - # secret_arn: "arn:aws:ssm:${AWS_DEFAULT_REGION}:${AWS_ACCOUNT_ID}:parameter/TestParameterFargateUpdate" - # context: [CPE-OIDC] - # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - # - aws-ecs/deploy_service_update: - # name: fargate_test-update_service-job - # auth: - # - aws-cli/setup: - # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - # profile_name: "ECS_TEST_PROFILE" - # filters: *filters - # requires: - # - fargate_test-update_service-command - # 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-OIDC] - # post-steps: - # - test-deployment: - # profile: "ECS_TEST_PROFILE" - # 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 - # auth: - # - aws-cli/setup: - # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - # profile_name: "ECS_TEST_PROFILE" - # filters: *filters - # requires: - # - fargate_test-update_service-job - # 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-OIDC] - # - 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-OIDC] - # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + - tear-down-test-env: + name: fargate_tear-down-test-env-initial + filters: *filters + aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_FARGATE} + terraform-config-dir: "tests/terraform_setup/fargate" + context: [CPE-OIDC] + role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + - 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-OIDC] + requires: + - fargate_tear-down-test-env-initial + 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-OIDC] + role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + - 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}" + secret_arn: "arn:aws:ssm:${AWS_DEFAULT_REGION}:${AWS_ACCOUNT_ID}:parameter/TestParameterFargateUpdate" + context: [CPE-OIDC] + role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + - aws-ecs/deploy_service_update: + name: fargate_test-update_service-job + auth: + - aws-cli/setup: + role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + profile_name: "ECS_TEST_PROFILE" + filters: *filters + requires: + - fargate_test-update_service-command + 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-OIDC] + post-steps: + - test-deployment: + profile: "ECS_TEST_PROFILE" + 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 + auth: + - aws-cli/setup: + role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + profile_name: "ECS_TEST_PROFILE" + filters: *filters + requires: + - fargate_test-update_service-job + 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-OIDC] + - 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-OIDC] + role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" # ################# # # EC2 # ################# @@ -677,135 +677,135 @@ workflows: # ################ # FargateSpot # ################ - # - test-fargatespot: - # context: [CPE-OIDC] - # filters: *filters - # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - # requires: - # - fargate_set-up-test-env + - test-fargatespot: + context: [CPE-OIDC] + filters: *filters + role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + requires: + - fargate_set-up-test-env ################# # CodeDeploy ################# - # - tear-down-test-env: - # name: codedeploy_fargate_tear-down-test-env-initial - # terraform-image: "hashicorp/terraform:1.4.0" - # aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE} - # terraform-config-dir: "tests/terraform_setup/fargate_codedeploy" - # context: [CPE-OIDC] - # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - # filters: *filters - # - build-test-app: - # name: codedeploy_fargate_build-test-app - # docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com" - # docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}:${CIRCLE_SHA1}" - # context: [CPE-OIDC] - # requires: - # - codedeploy_fargate_tear-down-test-env-initial - # 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.4.0" - # aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE} - # terraform-config-dir: "tests/terraform_setup/fargate_codedeploy" - # context: [CPE-OIDC] - # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - # - 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_REGION}.amazonaws.com" - # docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}:${CIRCLE_SHA1}" - # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - # skip-service-update: true - # context: [CPE-OIDC] - # - aws-ecs/deploy_service_update: - # name: codedeploy_fargate_test-update_service-job - # auth: - # - aws-cli/setup: - # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - # filters: *filters - # requires: - # - codedeploy_fargate_test-update_service-command - # region: $AWS_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_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: "80" - # codedeploy_capacity_provider_name: "FARGATE" - # codedeploy_capacity_provider_base: "1" - # codedeploy_capacity_provider_weight: "2" - # verify_revision_is_deployed: false - # context: [CPE-OIDC] - # 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 - # auth: - # - aws-cli/setup: - # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - # context: [CPE-OIDC] - # filters: *filters - # requires: - # - codedeploy_fargate_test-update_service-job - # region: $AWS_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_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: "80" - # 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 - # port: "8080" - # - 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.4.0" - # aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE} - # terraform-config-dir: "tests/terraform_setup/fargate_codedeploy" - # context: [CPE-OIDC] - # role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" - # filters: *filters - # - orb-tools/pack: - # filters: *release-filters - # - orb-tools/publish: - # orb_name: circleci/aws-ecs - # vcs_type: << pipeline.project.type >> - # pub_type: production - # enable_pr_comment: true - # context: orb-publisher - # 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] - # filters: *release-filters + - tear-down-test-env: + name: codedeploy_fargate_tear-down-test-env-initial + terraform-image: "hashicorp/terraform:1.4.0" + aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE} + terraform-config-dir: "tests/terraform_setup/fargate_codedeploy" + context: [CPE-OIDC] + role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + filters: *filters + - build-test-app: + name: codedeploy_fargate_build-test-app + docker-image-namespace: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com" + docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}:${CIRCLE_SHA1}" + context: [CPE-OIDC] + requires: + - codedeploy_fargate_tear-down-test-env-initial + 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.4.0" + aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE} + terraform-config-dir: "tests/terraform_setup/fargate_codedeploy" + context: [CPE-OIDC] + role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + - 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_REGION}.amazonaws.com" + docker-image-name: "${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE}:${CIRCLE_SHA1}" + role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + skip-service-update: true + context: [CPE-OIDC] + - aws-ecs/deploy_service_update: + name: codedeploy_fargate_test-update_service-job + auth: + - aws-cli/setup: + role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + filters: *filters + requires: + - codedeploy_fargate_test-update_service-command + region: $AWS_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_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: "80" + codedeploy_capacity_provider_name: "FARGATE" + codedeploy_capacity_provider_base: "1" + codedeploy_capacity_provider_weight: "2" + verify_revision_is_deployed: false + context: [CPE-OIDC] + 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 + auth: + - aws-cli/setup: + role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + context: [CPE-OIDC] + filters: *filters + requires: + - codedeploy_fargate_test-update_service-job + region: $AWS_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_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: "80" + 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 + port: "8080" + - 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.4.0" + aws-resource-name-prefix: ${AWS_RESOURCE_NAME_PREFIX_CODEDEPLOY_FARGATE} + terraform-config-dir: "tests/terraform_setup/fargate_codedeploy" + context: [CPE-OIDC] + role_arn: "arn:aws:iam::122211685980:role/CPE_ECS_OIDC_TEST" + filters: *filters + - orb-tools/pack: + filters: *release-filters + - orb-tools/publish: + orb_name: circleci/aws-ecs + vcs_type: << pipeline.project.type >> + pub_type: production + enable_pr_comment: true + context: orb-publisher + 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] + filters: *release-filters commands: wait-for-codedeploy-deployment: description: "Wait for the CodeDeploy deployment to be successful" diff --git a/src/commands/update_service.yml b/src/commands/update_service.yml index 84d5b32..dd822e3 100644 --- a/src/commands/update_service.yml +++ b/src/commands/update_service.yml @@ -273,7 +273,6 @@ steps: --query 'taskDefinition.taskDefinitionArn' \ --profile << parameters.profile_name >> \ --region << parameters.region >>) - echo "$TASK_DEFINITION_ARN" echo "export CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN=$TASK_DEFINITION_ARN" >> $BASH_ENV - when: condition: << parameters.task_definition_tags >> From e9cc80aa8873ac256f162a73caae9969de66209f Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Tue, 10 Dec 2024 12:44:04 -0500 Subject: [PATCH 28/28] Publish dev version --- .circleci/config.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 212586b..87c3100 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,8 +1,8 @@ version: 2.1 setup: true orbs: - orb-tools: circleci/orb-tools@12.0 - shellcheck: circleci/shellcheck@3.1 + orb-tools: circleci/orb-tools@12.2 + shellcheck: circleci/shellcheck@3.2 filters: &filters tags: @@ -19,6 +19,13 @@ workflows: filters: *filters - shellcheck/check: filters: *filters + - orb-tools/publish: + orb_name: circleci/aws-ecs + vcs_type: << pipeline.project.type >> + pub_type: dev + context: orb-publisher + requires: [orb-tools/lint, orb-tools/review, orb-tools/pack, shellcheck/check] + filters: *filters - orb-tools/continue: orb_name: aws-ecs pipeline_number: << pipeline.number >>