Question

Difficulty: MediumTroubleshooting CloudFormation and CI/CD Deployments

A developer is troubleshooting a CI/CD pipeline in AWS CodePipeline that deploys infrastructure using AWS CloudFormation. During the initial deployment of a new stack, the deployment stage failed due to an invalid parameter value, leaving the CloudFormation stack in the ROLLBACK_COMPLETE state. After correcting the parameter value in the template and pushing the fix to the source repository, the pipeline runs again but the CloudFormation deploy stage fails immediately, indicating that the stack cannot be updated. Which action must the developer perform to successfully deploy the stack through the pipeline?

  1. Delete the existing CloudFormation stack manually or via the AWS CLI, and then trigger the pipeline again.Answer
  2. B
    Execute the aws cloudformation continue-update-rollback CLI command to force the stack back to an active state, then trigger the pipeline.
  3. C
    Modify the trust policy of the CloudFormation execution role to allow the cloudformation.amazonaws.com service principal to assume the role, and then release the change.
  4. D
    Run drift detection on the stack to identify manually modified resources, resolve the drift, and trigger the pipeline.

Answer

Delete the existing CloudFormation stack manually or via the AWS CLI, and then trigger the pipeline again.
The correct answer is to delete the existing CloudFormation stack manually or via the AWS CLI, and then trigger the pipeline again. When a CloudFormation stack fails during its initial creation, it goes into the ROLLBACK_COMPLETE state. CloudFormation does not allow updates to a stack that has never been successfully created. Therefore, to proceed, the developer must delete the failed stack, which removes it, allowing the pipeline's subsequent run to perform a successful create operation.

Step-by-Step Solution

1
Identify the current status of the CloudFormation stack from the AWS CloudFormation console or CLI.
The stack is found to be in the ROLLBACK_COMPLETE state due to a failed initial creation.
Understanding the exact failure state is necessary because different rollback states (e.g., ROLLBACK_COMPLETE vs UPDATE_ROLLBACK_COMPLETE) have different recovery paths.
2
Determine the supported actions for a stack in the ROLLBACK_COMPLETE state.
A stack in ROLLBACK_COMPLETE cannot be updated; it can only be deleted.
This determines that attempting to push template updates through the pipeline directly will continue to fail, as the pipeline will attempt to perform a stack update action.
3
Delete the failed stack and re-run the pipeline.
The pipeline runs successfully and creates the stack from scratch with the corrected template.
Deleting the stack removes the blocked state, allowing the pipeline's CloudFormation action to execute a clean stack creation.

Key Concept

Handling CloudFormation initial creation failures and the ROLLBACK_COMPLETE state in CI/CD pipelines.
Rate this question