-
Notifications
You must be signed in to change notification settings - Fork 89
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
RFC 309: Loosely Coupled Cross Stack Ref #311
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
--- | ||
rfc pr: [#311](https://github.com/aws/aws-cdk-rfcs/pull/311) | ||
tracking issue: https://github.com/aws/aws-cdk-rfcs/issues/309 | ||
--- | ||
|
||
# [Loosely Coupled Cross Stack Ref] | ||
|
||
Use Parameter Store parameters for cross stack references | ||
|
||
## Working Backwards | ||
|
||
When passing object or class properties between stacks, instead of creating a CFN Export, | ||
Create a SSM Parameter in parameter store, then have the consuming stack create a parameter | ||
to consume the value from parameter store | ||
|
||
### CHANGELOG | ||
|
||
feat(core): loosely coupled cross stack references | ||
|
||
BREAKING CHANGE: Stacks will need to decouple their exports with dummy values | ||
|
||
### README | ||
|
||
#### Loosely Coupled Stack References | ||
|
||
By default when you pass a Stack property to another Stack cdk uses cloudformation exports and Fn::ImportValue to share | ||
the value cross stack. Adding `'@aws-cdk/core:looseCrossStackRefs'` to your cdk.json changes this behavior | ||
so that parameter store is used for storing and retrieving values across stacks | ||
|
||
## FAQ | ||
|
||
### What are we launching today? | ||
|
||
A new feature in core which enables stacks to be loosely coupled but maintain high cohesion by moving to parameters | ||
|
||
### Why should I use this feature? | ||
|
||
Creating standardized parameter store paths for values based on the stack we are deploying then consuming | ||
those cross stack using the native cloudformation parameterstore parameter type gives a lot of flexibility, | ||
allowing us to update resources as we need and then running stack updates on consuming stacks to pick up the | ||
new values | ||
|
||
## Internal FAQ | ||
|
||
### Why are we doing this? | ||
|
||
Prevent stacks being export locked and unable to update | ||
|
||
### Why should we _not_ do this? | ||
|
||
Exports lock resources for a reason. In some cases exports may be preferred. | ||
|
||
For example: | ||
|
||
- Resources may be temporarily unavailable while being replaced causing errors for downstream consumers. | ||
|
||
- If a stack outside of the app consumes the parameter, there is no tracking, so if the provider | ||
stack is torn down, other stacks may unexpectedly break. | ||
|
||
- For resources that have a more persistent lifecycle (VPCs, Subnets, etc) export locks are | ||
generally a non-issue | ||
|
||
### What changes are required to enable this change? | ||
|
||
A feature flag which changes the what gets returned when requesting a value from another stack | ||
|
||
### Is this a breaking change? | ||
|
||
Yes | ||
|
||
### What are the drawbacks of this solution? | ||
|
||
Tight coupling means the resources you are dependent on wont go away, in some instances | ||
this behavior prevents breaking consumers. | ||
Comment on lines
+73
to
+74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do you handle updates? You would need to notify the consumer stacks, right? Or rely on versioning? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm currently creating a dependency on the provider stack https://github.com/aws/aws-cdk/pull/13804/files#diff-d21961a629629b87c50d664aaf41594608e31d6ae693a2fc586062cdb3403eeeR175 The idea is when the provider is updated, it'll publish the new value and then cdk triggers a stack update on the dependent stacks and thats where they'll resolve the new parameter value. But perhaps that dependency isn't enough to force an update of the consumer stack after the provide has been updated? I'll have to verify that it works as expected. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've put some comments in aws/aws-cdk#13184 (comment) that can be related to this |
||
|
||
### What alternative solutions did you consider? | ||
|
||
Adding extra methods for storing and retrieving parameters from standardized paths, but | ||
this requires a lot of overhead when developing apps | ||
|
||
### What is the high level implementation plan? | ||
|
||
Add a feature flag, when the flag is enabled create a parameter and return a parameter for the consuming stack | ||
|
||
### Are there any open issues that need to be addressed later? | ||
|
||
## Appendix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd prefer the term "weak cross-stack references"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rix0rrr https://www.endoflineblog.com/cdk-tips-03-how-to-unblock-cross-stack-references describes the workaround necessary to delete a resource that's exported from one stack and consumed by another using the tightly-coupled approach. Moving to loosely-coupled puts the responsibility on the shoulders of the user, which, I think is reasonable, or at least it's an option I'd use if it were available.
I can't think of any case where the strong guarantees of export are enough of a benefit that I'd actually pick them over params. I would absolutely LOVE to be able to delete a stack which other stacks depend on. Because while it may sound like the wrong decisions and may even be the wrong decision most of the time, there are times when I could imagine it would be the best of a bunch of bad options.
I really like your observation about
both
mode though. I thing that the export model really needs to find a way to "still produce the required exports" in the case where resources are being deleted whether they're being replaced by params or just refactored out of the code in general.