Soru

Zorluk: ZorAWS CodeDeploy

A developer is configuring a blue/green deployment for an Amazon ECS service using AWS CodeDeploy. The deployment must execute a validation test against the newly deployed tasks (the green task set) before any production traffic is shifted. If the validation test fails, the deployment must automatically roll back. The developer is defining the AppSpec file in YAML format and configuring the IAM permissions. Which of the following configurations are required to meet these requirements? (Select TWO.)

  1. Define the validation Lambda function ARN under the BeforeAllowTraffic hook in the hooks section of the AppSpec file.Cevap
  2. Grant the CodeDeploy service role the lambda:InvokeFunction permission for the validation Lambda function.Cevap
  3. C
    Define a local shell script path under the BeforeAllowTraffic hook in the hooks section of the AppSpec file to execute the validation tests.
  4. D
    Attach the lambda:InvokeFunction permission to the Amazon ECS Task Execution Role to allow the task containers to invoke the validation Lambda function.
  5. E
    Define the validation Lambda function under the ValidateService hook in the hooks section of the AppSpec file.

Cevap

Defining the validation Lambda function ARN under the BeforeAllowTraffic hook and granting the CodeDeploy service role the lambda:InvokeFunction permission.
The correct configurations involve using the BeforeAllowTraffic lifecycle hook inside the ECS AppSpec file to point to the validation Lambda function, and ensuring the CodeDeploy service role has the lambda:InvokeFunction permission to run it. The BeforeAllowTraffic hook executes after the green task set is provisioned but before production traffic shifts, enabling testing and automatic rollback on failure.

Adım Adım Çözüm

1
Identify the target compute platform and the required validation timing.
The target platform is Amazon ECS and the validation must run before production traffic is shifted.
This establishes that we must use ECS-compatible AppSpec lifecycle hooks.
2
Determine the correct AppSpec hook and execution format for ECS.
For ECS, AppSpec lifecycle hooks can only target AWS Lambda functions, and the BeforeAllowTraffic hook runs before the production traffic shifts.
This rules out using shell scripts (which are EC2-only) and EC2-specific hooks like ValidateService.
3
Determine the required IAM permissions.
CodeDeploy executes the lifecycle hook, so the CodeDeploy service role requires permission to invoke the validation Lambda function.
This distinguishes it from ECS Task Execution permissions, as the task is not the caller of the validation function.

Anahtar Kavram

AWS CodeDeploy ECS Blue/Green lifecycle hooks and IAM permissions
Bu soruyu puanla