Skip to content

Cloudformation Drift issue

0

Hello,

I have few resources deleted by mistake which was created as part of cloudformation stack, Now, Cloudformation stack is showing drift but not able to reprovision the delete resources on upload the same template. Please help how on reprovision the delete resources without deleting the Cloudformation stack because it has other resources component as well.

asked 2 years ago773 views

2 Answers
1

To address your CloudFormation drift issue and reprovision the accidentally deleted resources without deleting the entire stack, you can follow these steps:

  1. First, identify the logical IDs of the resources that were deleted outside of the CloudFormation stack.

  2. In your CloudFormation template, assign new logical IDs to these deleted resources. For example, if you had an S3 bucket with the logical ID "S3Bucket", you could rename it to "S3NewBucket".

  3. Update all references to the old logical IDs throughout your template, replacing them with the new logical IDs you just created.

  4. After making these changes, update your CloudFormation stack using the modified template. This update operation will cause CloudFormation to recreate the deleted resources with the new logical IDs, while leaving the existing resources untouched.

It's important to note that this method works because CloudFormation interprets the resources with new logical IDs as new resources to be created, rather than updates to existing (but deleted) resources.

After performing these steps, you should run a drift detection operation on your stack to ensure that all resources are now in sync with the template.

If you encounter any issues during this process, you may need to check for dependencies between resources or review the specific error messages provided by CloudFormation. In some cases, you might need to adjust the order of resource creation or add explicit dependencies using the DependsOn attribute in your template.

Remember that drift detection might not always provide perfectly accurate results in all scenarios, so it's crucial to double-check the actual state of your resources after performing these operations.
Sources
Recreate a resource deleted outside CloudFormation | AWS re:Post
Detect unmanaged configuration changes to stacks and resources with drift detection - AWS CloudFormation
Troubleshooting CloudFormation - AWS CloudFormation

answered 2 years ago

EXPERT

reviewed 2 years ago

1

Hi,

You probably want to follow precisely the steps of this KC article: https://repost.aws/knowledge-center/cfn-recreate-resource-deleted-outside

Best

Didier

EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.