-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SSM Dynamic Reference Change not detected #844
Comments
I can confirm that issue. I created lambda with resolve ssm as a key object in cloudformation template. Then I deployed the stack.
Any updates later couldformation does not see any changes perhaps that parameter store has a new value and version. |
@robot-apocalypse are you doing an update stack while using the existing template? I was getting different results based on if I supplied a template or used the existing one. I'm curious if you also tried both approaches or not. |
Had a discussion with support and heard this wasn't fixed yet.
Had a workaround, plug a random source (e.g. timestamp) into metadata to force a change set
Of course would very like to hear that this get fixed, and don't have to litter the Metadata everywhere in the template. |
How can we push this bug up? |
+1 |
1 similar comment
+1 |
I thought it should be a simple fix in change set creation, like when the syntax is It is incorrect to assume that if the text It haven't been fixed for another half year, and our team had written a simple github action that checks if every resource that used
|
I understood the idea with Metadata, I don't like it because it causes rebuilding every time and when you have a lot of resources it takes really a lot of time. My workaround: I use just regular parameters instead of |
I believe I have a workaround for Secrets Manager (haven't tested with SSM). As the VersionId is updated every time you perform an update to a secret, you can use the AWS SDK/CLI to grab that VersionID and append it your dynamic reference in your CF template. This is stated in the document as version-id https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html#dynamic-references-secretsmanager-pattern For example I could run this CLI query: (aws secretsmanager list-secret-version-ids That would grab the latest VersionID that matches the AWSCURRENT version stage and them pass that through as a parameter to your template, looking something like this:
|
There is one more thing you need to know, on top of the solution with the random/updated value. If you have this code, the parameter will still not update a second time
In most case you will not run into this, as either you have a dynamic value you're using in the !Sub, or you are using a For reference, if you want to hardcoded a value with a resolve (should only be needed during testing), you can write.
|
The introduction of this GitHub issue seems a little misleading to me. Scenario 1 and Scenario 2 mentioned in this Github issue seem to detect the changes just fine. I am not sure why its mentioned that these two scenarios do not detect change. Following is my observation for these three scenarios: Scenario 1: changing {{resolve:ssm:test}} to {{resolve:ssm:new}} in the template using:
Outcome: ChangeSet created successfully/ Update successful Scenario 2: changing {{resolve:ssm:test:1}} to {{resolve:ssm:test:2}} in the template using:
Outcome: ChangeSet created successfully/ Update successful Scenario 3: Using ssm dynamic reference without parameter version like below in order to fetch latest value and then changing the ssm parameter value in SSM without changing anything in the template:
Outcome: ChangeSet creation fails/ Update fails with error: No updates are to be performed. Its only in Scenario 3 i.e. when the value of the SSM parameter is changed without changing the template that the Changeset creation fails. This happens because CFN does not have a way at that time to check if the resolved value of the dynamic reference has changed or not as dynamic references are resolved when you execute the change set (not at the time of change set creation), as mentioned in the AWS official doc. So in order to trigger a stack update in this case and to also fetch the latest parameter version from parameter store during that stack update, it becomes important to update the resource containing the dynamic reference, either by updating the resource property that contains the dynamic reference, or by updating another of the resource's properties. Now, one way to do that is by using parameter versions in the dynamic reference in the template and have a system in place to match the latest version of the parameter in the parameter store with the version present in the template. If this method is not suitable, then the following workaround can also come handy for this use-case:
|
@benbridts Hi, you can then remove the unnecessary @Arushi1597 Yes, it is only case 3 that didn't work, am testing again now and still not fixed. |
I expected case 3 to work, but it doesn't. Is it so hard to resolve ssm parameters and after that create change set with new latest version? |
I can only second what @Arushi1597 wrote in Scenario 3. |
I have the same issue. Dynamic ssm references are not getting resolved during a change set creation and therefore end up in "no changes found" although the value of the latest version of a ssm parameter hast changed. eg: But when I change the value of the parameter Ec2InstanceProfileName in the SSM Parameter store and create a change set for the CF stack, which manages the EC2 instance, there is no change set created (and therfor the EC2 instance not updated), becasue CF does not determine a change in the template. |
It is likely a problem with the way changeset is created, hypothesis here is based on the fact that if you skip changeset creation and do an update, the actual parameter gets updated, and also adding random metadata will cause a correct update.
Dynamic reference is not a part of template resolution, so remains as
So no change detected. As long as you make some change, even to the metadata, an actual cloudformation update to the resource is performed, there seem no such diff issue above in the update implementation
|
When using SSM Dynamic references, if the reference or resolved value changes, cloudformation does not detect the change and will not update the stack.
Scenario 1: changing {{resolve:ssm:/dev/pipeline/GitHubOwner}} to {{resolve:ssm:/production/pipeline/GitHubOwner}} in the template
Scenario 2: changing {{resolve:ssm:/dev/pipeline/GitHubOwner:10}} to {{resolve:ssm:/dev/pipeline/GitHubOwner:11}} in the template
Scenario 3: changing the value of the parameter without changing the template (using new 'latest' functionality)
I would expect all three scenarios to be recognized as a change and allow the stack to be updated, instead I get
"No changes to deploy. Stack production-pipeline is up to date"
The text was updated successfully, but these errors were encountered: