Soru

Zorluk: ZorAWS CodeDeploy

A developer is configuring an AWS CodeDeploy deployment group for an in-place deployment of a web application to Amazon EC2 instances. The deployment must automatically revert to the last known successful version if the new deployment fails or if application error rates exceed a specific threshold. Additionally, the developer needs to ensure that any temporary files left by a failed deployment are cleaned up during the rollback process.

Which of the following configurations should the developer implement to meet these requirements? (Select TWO.)

  1. Enable automatic rollbacks in the CodeDeploy deployment group settings for deployment failures, and configure a CloudWatch alarm to trigger a rollback when application error rates exceed the threshold.Cevap
  2. Implement the cleanup script within the BeforeInstall lifecycle hook of the application's AppSpec file, because CodeDeploy rolls back by executing a new deployment of the last successful revision.Cevap
  3. C
    Add a Rollback hook to the hooks section of the appspec.yml file to execute a script that automatically deletes temporary files when a rollback is initiated.
  4. D
    Attach a service role to the CodeDeploy agent on the EC2 instances with a trust policy that permits the sns:Publish action for rollback alerts.
  5. E
    Store the cleanup script in AWS Systems Manager Parameter Store as a secure parameter, and reference it under the resources section of the appspec.yml file.

Cevap

Enable automatic rollbacks in the CodeDeploy deployment group settings for deployment failures and CloudWatch alarm states, and implement cleanup logic in the BeforeInstall hook of the AppSpec file because CodeDeploy performs a rollback by initiating a new deployment of the last successful revision.
The correct configurations are to enable automatic rollbacks in the CodeDeploy deployment group for both deployment failures and when a configured CloudWatch alarm (tracking error rates) goes into the ALARM state. Furthermore, because CodeDeploy executes a rollback by initiating a new deployment of the last successful revision, the cleanup logic must be placed in a standard lifecycle hook such as BeforeInstall of that revision to ensure any leftover artifacts from the failed deployment are deleted before files are copied.

Adım Adım Çözüm

1
Configure rollback behaviors on the deployment group
Automatic rollbacks are enabled for deployment failures and CloudWatch alarms monitoring error rate thresholds.
This natively automates the rollback process when a failure is detected or when application metrics degrade.
2
Analyze how CodeDeploy executes rollbacks
CodeDeploy handles rollbacks by running a brand new deployment of the previous successful revision.
Understanding this flow reveals that there is no custom Rollback hook; instead, standard deployment hooks in the target revision will run.
3
Place the cleanup script in the correct lifecycle hook of the AppSpec file
The cleanup script is mapped to the BeforeInstall hook of the AppSpec file.
When the rollback deployment starts, the BeforeInstall hook runs before new files are copied, clearing out remnants of the failed deployment.

Anahtar Kavram

AWS CodeDeploy rollbacks are executed as new deployments of the last known successful revision, which run the standard AppSpec lifecycle hooks of that revision rather than a dedicated rollback hook.
Bu soruyu puanla