Skip to content

Cannot spot drift in CloudFormation template

0

I'm new to CloudFormation. I created a stack indirectly by creating an elastic beanstalk environment. The stack has a bit of drift because I made some changes using the AWS console after the environment was created. I'd like to keep these changes and update the template.

But when I export the template (using StackDetails->Template) and open it in a file, it seems like the "template" reflects my current configuration - not the original CloudFormation template. Specifically, when I try to find some removed resources (that show up as MODIFIED in Stack->Drifts) I cannot see them in the exported template.

Does the template reflect my current configuration instead of the original?

FWIW I think AWS should implement a single click "Update stack with current configuration".

2 Answers
1

The bot is confusing things. The template shown for the stack is the template you used to create your stack or, if you updated the stack subsequently, the template you used in the latest update that completed.

The template does NOT reflect any changes made to the resources without going through CloudFormation.

As the bot wrote in the latter part of its reply, you have to modify the template manually based on either your own understanding of the changes or the drift details shown by CloudFormation's drift detection, and then update the stack with the template you updated manually.

Edit: I updated the bot's reply to eliminate the confusion.

EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

0

The template shown for the stack is the latest version of the template used to deploy or update the stack. It does not reflect any changes made directly to the underlying AWS resources, without updating the CloudFormation stack.

For drift detection, CloudFormation compares the actual current state of your resources with the expected state as defined in the currently deployed template for the stack. The drift you're seeing (resources marked as MODIFIED in Stack->Drifts) represents the differences between the original template plus any updates and the current state of your resources.

Regarding your suggestion for a "Update stack with current configuration" feature, AWS doesn't currently offer this as a one-click solution. To update your stack:

  1. Detect drift on your stack
  2. Review the drift results
  3. Manually update your template to incorporate the changes you want to keep
  4. Update the stack with your modified template

This process allows you to make conscious choices on which changes to keep and which to revert, giving you more control over your infrastructure configuration.

Remember, it's strongly advisable to make changes through CloudFormation rather than directly in the console to keep your infrastructure as code in sync with the actual state of your resources.

Sources
Detect unmanaged configuration changes to stacks and resources with drift detection - AWS CloudFormation
DetectStackDrift - AWS CloudFormation
Performing drift detection on CloudFormation StackSets - AWS CloudFormation

answered 2 years ago

EXPERT

reviewed 2 years ago

EXPERT

revised 2 years ago

  • If I understand you correctly, I can execute the "Update stack with current configuration" by:

    1. Downloading the template (which reflects my current changes)
    2. Updating the stack with that template

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.