Soru

Zorluk: OrtaAWS CodeDeploy

A development team is setting up a continuous delivery pipeline using AWS CodeDeploy for a microservice hosted on Amazon Elastic Container Service (Amazon ECS). The team wants to ensure that a validation test suite is executed immediately after the new container tasks are registered and test traffic is routed to them, but before any production traffic is shifted. Additionally, they want to execute a notification task once the production traffic has been completely transitioned.

Which actions must the developer take to achieve this deployment workflow? (Select TWO.)

  1. Define the AfterAllowTestTraffic hook in the appspec.yaml file to invoke a Lambda function that executes the validation tests.Cevap
  2. Define the AfterAllowTraffic hook in the appspec.yaml file to invoke a Lambda function that executes the notification task.Cevap
  3. C
    Define the ApplicationStart and ApplicationStop hooks in the appspec.yaml file to run the validation tests and the notification task.
  4. D
    Update the trust policy of the Amazon ECS task execution role to trust the codedeploy.amazonaws.com service principal.
  5. E
    Store the notification service credentials in AWS Systems Manager Parameter Store as a Standard Parameter with a String data type for retrieval by the validation script.

Cevap

To configure this ECS deployment workflow, the developer must define the AfterAllowTestTraffic hook in the appspec.yaml file to execute the validation tests, and define the AfterAllowTraffic hook to run the post-traffic routing notification task.
For an Amazon ECS deployment, CodeDeploy uses a specific set of hooks. The 'AfterAllowTestTraffic' hook runs after the replacement tasks are created and test traffic is routed to them, making it the ideal stage for running integration/validation tests. The 'AfterAllowTraffic' hook runs after all production traffic is shifted to the new task set, which is the correct moment to trigger a notification task confirming completion.

Adım Adım Çözüm

1
Identify the target compute platform and its specific lifecycle hooks.
The platform is Amazon ECS. ECS-specific hooks must be used rather than EC2-specific ones.
AWS CodeDeploy uses distinct lifecycle hooks depending on the target compute platform.
2
Determine the correct lifecycle hook for the validation tests.
Validation tests must run after test traffic is active but before production traffic starts shifting, which matches the AfterAllowTestTraffic hook.
This hook fires as soon as the test port is serving traffic to the new task set.
3
Determine the correct lifecycle hook for post-deployment notification.
The notification must run after the shift of production traffic is completed, which corresponds to the AfterAllowTraffic hook.
This hook fires immediately after the production traffic routing is successfully fully swapped.

Anahtar Kavram

AWS CodeDeploy Lifecycle Hooks for ECS

Alternatif Yöntem

Instead of executing tests strictly in AfterAllowTestTraffic, you can also use AfterInstall to perform tests if you do not have a separate test port configured, though AfterAllowTestTraffic is the standard best practice when test traffic routing is configured.
Tahmini Süre:1m 30s
Bu soruyu puanla