Cloudformation Accidentally change bucket name

1

Hi, I have a Cloudformation template, which creates a couple of resources, an IAM user, an access key, roles and an S3 bucket.

I re-used the same template to create another bucket and ran the command from the CLI. I, however, neglected to update the "--stack-name" parameter, and the update started taking place on the existing stack and not a new one.

The new stack has a new value for the bucket name, and went ahead and created a new bucket, then attempted to delete the old bucket, which contains data, so it could not be deleted. I can, however now not roll back to a state where it will use the existing bucket name, to enable me to manage the original stack anymore.

I have done a test run by creating a bucket and then importing that into a test stack. This works for the import, however once imported, it does not allow me to make any changes to the import bucket. A current setting on the bucket is

      ObjectLockEnabled: true
      VersioningConfiguration:
        Status: Enabled

If I have this option in the cloudformation template, it requires replacement. Yet the setting is currently in place already, I just need the template to match what is in place.

Any advice?

Bobk
asked a year ago374 views
2 Answers
0

I've been in situations like this where the actual state and the state CloudFormation thinks it is in are out of sync. You can either revert the change and have CloudFormation attempt to change it, but if that causes a replacement it isn't ideal. Or I've contacted AWS support and they have been able to correct the state on the CloudFormation backend.

Very similar to this discussion: https://stackoverflow.com/questions/54386020/how-to-fix-a-drifted-aws-cloudformation-stack

answered a year ago
0

Thank you for the reply. The account, unfortunately, only has basic support, so I am not sure if they will assist. I will test the import option more and see what happens if I don't add the Object lock from my side. If it will keep the template In a way where I can at least make future changes while it ignores the ones it didn't want to import.

Bobk
answered a year 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.

Guidelines for Answering Questions