AWS Certified Developer – Associate (DVA-C02)Troubleshooting and MonitoringMedium
A developer is using AWS CloudFormation to deploy an application. After a recent update to a stack, the deployment is stuck in an 'UPDATE_ROLLBACK_FAILED' state. Upon reviewing the CloudFormation events, they see an error indicating 'The following resource(s) failed to update: [MyEC2Instance]'. The EC2 instance itself appears to be running, but the stack remains stuck. What is the MOST appropriate next step to resolve this issue and re-enable stack operations?
- ADelete the entire CloudFormation stack and redeploy it from scratch.
- BUse the `aws cloudformation cancel-update-stack` command to force the stack into a stable state.
- CManually terminate the 'MyEC2Instance' and then attempt to update the stack again.
- DUse the `aws cloudformation continue-update-rollback` command, potentially with resource skipping, to reconcile the stack state.
Show answer & explanationAnswer & explanation
Correct answer: D. Use the `aws cloudformation continue-update-rollback` command, potentially with resource skipping, to reconcile the stack state.
When a CloudFormation stack enters 'UPDATE_ROLLBACK_FAILED', it signifies that CloudFormation encountered an issue during a rollback operation and cannot proceed. The `continue-update-rollback` command is specifically designed for this scenario, allowing you to either continue the rollback or skip problematic resources to bring the stack back to a stable state.
Why the other options are wrong
- A. Deleting and redeploying is a drastic measure that results in downtime and data loss. It should only be considered if recovery attempts fail.
- B. There is no `cancel-update-stack` command. `cancel-update-stack` is not a valid AWS CLI command. CloudFormation has `cancel-update-stack` for stacks in UPDATE_IN_PROGRESS, but not for FAILED states.
- C. Manually terminating resources while CloudFormation is in a failed state can lead to further state inconsistencies and is generally not recommended without specific guidance.
CloudFormation Rollback Failure
A CloudFormation stack enters `UPDATE_ROLLBACK_FAILED` when it cannot successfully revert changes during a failed update, leaving it in an inconsistent state.
- Prevents further stack operations.
- Often caused by dependencies, manual changes, or issues with resource deletion.
- `continue-update-rollback` is the primary recovery mechanism.
Memory trick: When CloudFormation's rollback stumbles, 'continue' is the key.