custom-resources: AwsCustomResource not using latest value #21034
Replies: 3 comments
-
Note that deleting the stack that fails to use the latest value, and then creating it again, seems to solve the problem. |
Beta Was this translation helpful? Give feedback.
-
You need to understand CloudFormation for this -- it will assume that the result of a resource update, any resource update, is idempotent. If the properties of a resource didn't change, it will not perform the update again. So, even if you Lambda would have produced a different output when run again, it will never be run because its input didn't change. If you can control an input parameter that is not used, and put a value like the current timestamp there, that will invalidate the execution. Or, if you change the logical ID, that will make CFN treat the resource as a different resource which also invalidates it. |
Beta Was this translation helpful? Give feedback.
-
It is unclear what you want the requester to do to fix the problem. Here are the aws docs suggesting to set physicalResourceId to Date.now(). What should the requester do differently? |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
I created a custom resource that reads parameters from parameter store in various regions. For some resources it fails to use the latest value.
Specifically in my case, I deleted and re-created a Hosted Zone, exporting the hosted zone name and IDs as parameters to parameter store, which I want to import in other stacks.
Expected Behavior
It should always fetch the latest value from parameter store.
Current Behavior
I can see the associated lambda function running and returning the correct value. However, when the stack deploys, it seems to be trying to use the old value for the hosted zone ID.
Reproduction Steps
I use the following construct:
Then you can use this construct to import various parameters. Because the physical ID updates each deployment, it always tries to fetch the latest value. The logs show it working correctly:
The line
"Parameter.Value": "<CORRECT_HOSTED_ZONE_ID_HERE>"
refers to the correct value, the current hosted zone Id. But when deploying a stack using this construct, I get the errorPossible Solution
No response
Additional Information/Context
No response
CDK CLI Version
1.124.0
Framework Version
1.144.0
Node.js Version
14.17
OS
macos
Language
Typescript
Language Version
No response
Other information
No response
Beta Was this translation helpful? Give feedback.
All reactions