Soru

Zorluk: OrtaTroubleshooting CloudFormation and CI/CD Deployments

A developer is configuring a CI/CD pipeline in AWS CodePipeline that uses AWS CodeDeploy to perform a blue/green deployment for a microservice running on Amazon ECS. The developer defines a set of deployment lifecycle hooks in the appspec.yaml file to run Lambda functions that perform integration tests. The pipeline fails during the deployment phase, and the CodeDeploy deployment log shows that the appspec.yaml contains an invalid lifecycle hook. The appspec.yaml includes the 'BeforeInstall', 'ApplicationStart', and 'AfterAllowTraffic' hooks. Which of the following is the primary cause of this deployment failure?

  1. A
    The CodeDeploy service role lacks a trust policy allowing the Amazon ECS service to assume the role, preventing the validation of the lifecycle hooks.
  2. B
    The ECS Task Execution Role is missing the required permissions to execute the container commands defined under the ApplicationStart phase.
  3. The 'ApplicationStart' hook is an EC2/On-Premises deployment lifecycle hook and is not supported in Amazon ECS deployments.Cevap
  4. D
    The CloudFormation stack managing the ECS service is currently in the ROLLBACK_COMPLETE state, blocking any new CodeDeploy lifecycle hooks from running.

Cevap

The 'ApplicationStart' hook is an EC2/On-Premises deployment lifecycle hook and is not supported in Amazon ECS deployments.
In Amazon ECS deployments, AWS CodeDeploy supports a specific, limited set of lifecycle hooks to run Lambda validation functions: BeforeInstall, AfterInstall, AfterAllowTestTraffic, BeforeAllowTraffic, and AfterAllowTraffic. The ApplicationStart hook is specific to EC2/On-Premises deployments (which also include ApplicationStop, BeforeInstall, Install, AfterInstall, ValidateService, etc.). Including ApplicationStart in an ECS appspec.yaml file results in a validation failure during the deployment phase.

Adım Adım Çözüm

1
Identify the deployment target and configuration context from the error message.
The target is Amazon ECS using CodeDeploy, and the failure is caused by an invalid lifecycle hook in the appspec.yaml file.
Understanding the target environment (ECS vs EC2) determines which AppSpec structure and hook names are valid.
2
Compare the hook names provided in the scenario with the list of supported hooks for ECS deployments.
ECS deployments support hooks like BeforeInstall, AfterInstall, AfterAllowTestTraffic, BeforeAllowTraffic, and AfterAllowTraffic. The hook 'ApplicationStart' is only supported in EC2/On-Premises deployments.
Mismatched lifecycle hooks between platforms cause validation errors in AWS CodeDeploy.
3
Select the option that correctly identifies the invalid hook and the target compatibility mismatch.
The correct option is the one stating that 'ApplicationStart' is an EC2-specific hook and not supported in ECS.
This directly matches the root cause of the AppSpec parsing/validation failure in CodeDeploy.

Anahtar Kavram

AWS CodeDeploy AppSpec lifecycle hooks differ significantly between EC2/On-Premises and Amazon ECS deployment types.
Tahmini Süre:1m 30s
Bu soruyu puanla