A developer is writing an appspec.yml file for an in-place deployment to Amazon EC2 instances using AWS CodeDeploy. The developer needs to execute a shell script to gracefully stop the running web server application before the new deployment bundle is downloaded. Additionally, the script requires retrieving database credentials that must undergo automatic rotation. How should the developer configure the deployment to meet these requirements?
- ASpecify the script under the BeforeAllowTraffic lifecycle hook in the appspec.yml file, and retrieve the credentials dynamically from AWS Secrets Manager using the AWS CLI within the script.
- BSpecify the script under the BeforeInstall lifecycle hook in the appspec.yml file, and configure the EC2 instance profile's IAM trust policy to trust the CodeDeploy service to allow the script to execute.
- Specify the script under the ApplicationStop lifecycle hook in the appspec.yml file, and retrieve the credentials dynamically from AWS Secrets Manager using the AWS CLI within the script.Cevap
- DSpecify the script under the ApplicationStop lifecycle hook in the appspec.yml file, and configure AWS Systems Manager Parameter Store to automatically rotate the database credentials.
Cevap
Specify the script under the ApplicationStop lifecycle hook in the appspec.yml file, and retrieve the credentials dynamically from AWS Secrets Manager using the AWS CLI within the script.
The correct configuration is to target the ApplicationStop lifecycle hook. In an EC2 in-place deployment, ApplicationStop is the first hook to execute and runs before the new deployment bundle is downloaded (DownloadBundle phase). Additionally, AWS Secrets Manager is the correct service for retrieving the rotated database credentials, as it natively supports automatic rotation of secrets, unlike Systems Manager Parameter Store.
Adım Adım Çözüm
Anahtar Kavram
CodeDeploy EC2 Deployment Lifecycle Hooks and Secrets Management
Tahmini Süre:1m 30s