Question

Difficulty: Very hardDeployment Strategies and Execution

A company runs a critical microservice on Amazon ECS using the AWS Fargate launch type. A SysOps administrator is configuring a blue/green deployment strategy using AWS CodeDeploy to update the ECS service.

The deployment must satisfy the following operational requirements:
- Route a small fraction of test traffic to the new task set (green environment) using a test listener on port 80808080 to perform integration tests.
- Automatically roll back to the original task set (blue environment) if the integration tests fail or if the Application Load Balancer (ALB) green target group's `HTTPCode_Target_5XX_Count` metric exceeds a threshold during the deployment.
- The rollback must occur automatically without manual intervention.

Which two configurations must the SysOps administrator implement to meet these requirements? (Select two.)

  1. Specify an AWS Lambda function under the AfterAllowTestTraffic hook in the AppSpec file to execute the validation tests.Answer
  2. Create a CloudWatch alarm for the HTTPCode_Target_5XX_Count metric of the green target group, and associate it with the CodeDeploy deployment group's rollback configuration.Answer
  3. C
    Specify the validation tests under the BeforeInstall hook in the AppSpec file to ensure the new container image functions before task set creation.
  4. D
    Configure the CodeDeploy service role trust policy to allow sts:AssumeRole for the Amazon ECS task execution role to grant task deployment permissions.
  5. E
    Create a CloudWatch alarm for the HTTPCode_Target_5XX_Count metric of the blue target group, and configure an Amazon EventBridge rule to invoke a custom rollback function.

Answer

The configurations that specify an AWS Lambda function under the AfterAllowTestTraffic hook in the AppSpec file, and create a CloudWatch alarm for the HTTPCode_Target_5XX_Count metric of the green target group associated with the CodeDeploy rollback settings are correct.
Executing integration tests under the AfterAllowTestTraffic hook in the AppSpec file ensures the tests run against the replacement task set while it is receiving test traffic through the test listener port. Associating a CloudWatch alarm that monitors the 5XX error count of the green target group with the CodeDeploy deployment group's rollback configuration ensures that any errors generated during testing trigger an automatic rollback to the original task set.

Step-by-Step Solution

1
Determine the correct CodeDeploy lifecycle hook for running integration tests against the new task set via the test port.
The AfterAllowTestTraffic hook is identified because it runs after the test listener starts routing traffic to the replacement (green) task set.
This allows validation tests to run against the new version before any production traffic is shifted.
2
Identify the target group to monitor for deployment quality.
The green target group must be monitored because it receives the test traffic for the new version during the validation phase.
Monitoring the blue target group would only detect errors on the old version, failing to capture deployment issues.
3
Configure automatic rollback integration in AWS CodeDeploy.
A CloudWatch alarm is created on the green target group's 5XX metrics and added to the CodeDeploy deployment group rollback settings.
This enables native, automatic rollbacks without needing custom automation scripts or manual intervention.

Key Concept

AWS CodeDeploy blue/green deployments for Amazon ECS utilize lifecycle hooks (specifically AfterAllowTestTraffic) for running validation tests and native CloudWatch alarm integration to trigger automatic, zero-downtime rollbacks when errors are detected on the replacement task set.
Rate this question