Skip to content

Commit 8848134

Browse files
authored
feat(core): support adding additional cache key to cdk context values (#31586)
### Issue # (if applicable) Closes #26982 ### Reason for this change The ContextProvider mechanism and various "lookup" functions of a number of constructs support caching resolved values in the cdk.context.json. The context keys are constructed from the parameters of the lookup, which for lookup functions means whenever a resource with the same parameters is resolved, it is resolved as the same value across the entire app. However when a value may change over time, the user may wish to use the latest value when creating creating a new reference to the construct, effectively tying the cached context value to the scope - this patch enables this. The primary use case is looking up an AMI parameter for a "stateful" EC2 instance. Currently if you specify cachedInContext, any future images created would use the same cached AMI, and updating the value would require updating all usages of the image across the entire app. ### Description of changes Adds an `additionalCacheKey` parameter/property to multiple areas of the CDK where lookups can be cached ### Description of how you validated changes Unit + integration tests ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 4e63b1a commit 8848134

23 files changed

+2794
-17
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image-cached.js.snapshot/cdk-ec2-machine-image-cached.assets.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)