How to fix a CloudFormation stack that references an SSM Parameter that's been removed

0

I have a CloudFormation stack that uses Dynamic References of an SSM Parameter.

I was refactoring my stack, so that I could launch multiple copies of them that wouldn't conflict. In the process, I moved the one of the dynamic references, to an input on the stack, and removed the backing SSM Parameter.

Unfortunately, I removed the Parameter before I updated the stack, and now the stack seems to be locked in a weird state. When I try to create a Update the stack with a template with the parameter removed, it creates a Change Set, but the Change Set Fails with the status reason

Parameters: [ssm:<redacted>:1:1694494367727] cannot be found.

I tried creating the SSM Parameter again, but now it fails with

Parameters: [ssm:<redacted>:1:1694494367727] last modified date does not match with the last modified date of the retrieved parameters.

I suspect that I've hit a weird bug in an edge case. Is there any way for me to update my stack without breaking everything?

asked 2 months ago229 views
1 Answer
0

Hi.

This error occurs due to a known bug where CloudFormation when dynamically references SSM parameters, it doesn't pick up the latest timestamp from SSM parameter store.

Here is the recommended workaround to resolve this issue:

  1. Recreate the SSM parameter.

  2. Get the new parameter timestamp using the command $aws ssm get-parameter --name ‘the name of the ssm parameter’. The timestamp is LastModifiedDate. You'll need to convert it to a Unix timestamp with milliseconds. You can do it by pasting the date here and copying the appropriate formatted value.

  3. Copy the processed template entirely and save it to a file (you'll have to edit and upload it later).

  4. Update the template file with the new SSM Parameter (correct the version and the timestamp for the ssm parameter)

  5. In your stack, click Update, choose "Replace current template", and "Upload a template file". Pick the new template file you've just corrected.

  6. Finish the wizard by clicking Next until the last step, and finally click Update stack.

AWS
SUPPORT ENGINEER
answered 2 months ago
profile picture
EXPERT
reviewed 22 days 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