-
Notifications
You must be signed in to change notification settings - Fork 456
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
feat(lib): cross-stack references #1416
Conversation
64abbbc
to
fd2f6a6
Compare
Does this supersede #1179? There were some comments there that may still apply here. |
Yes it will, I left the other PR open so that I don't forget to look through the comments |
f15983d
to
3d560ea
Compare
test/typescript/cross-stack-references/__snapshots__/test.ts.snap
Outdated
Show resolved
Hide resolved
f439f63
to
524cb51
Compare
Just came across this when reading a former proposal for cross stack references I did a while back: aws/aws-cdk#12778 |
996069f
to
acc2966
Compare
f59e3f4
to
1c3f787
Compare
When we have a stack that in one run uses a cross stack reference and in the other not there would be an empty local backend configuration in one cases vs the other This prevents removing a cross stack reference in case no backend is configured
5c88ec1
to
6420858
Compare
@skorfmann does this test case cover your concern around complex computed lists or did I do sth wrong here? 103a5be |
The links appear to be broken. But anyway, if it works that's ok. |
I think it would be good to have this properly working from the beginning, seems very unexpected to me. |
It's not really straightforward to understand what's actually being tested there. Here's my case: I was passing the entire domain validation options object (ComplexComputedList), not a single element. Not even sure if that's a thing which should be working or which should be caught with an error. |
So, this should raise an error when referencing across stacks then, correct? |
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.
Haven't gone through the code since others did this already. As laid out in the comments I'd add a few more explicit errors for things which are not working (yet). Plus, the functions magically appearing in a referencing stack should be fixed. Other than that, I think it's good and works as expected 👍
I'm going to create follow up issues for the outstanding work and mention them here 👍 |
|
Is there an example of how to do this in python? |
We have a test case in Python, hope that helps :) https://github.com/hashicorp/terraform-cdk/blob/main/test/python/cross-stack-references/main.py The usage is pretty similar to Typescript, passing a value created in one stack into another one does the trick |
@DanielMSchmidt Thanks that is helpful. However, I am trying to pass an aws ARN from one stack to another. When i set it in one stack and reference it in another, the variable gets set as ${module.s3_bucket_id.s3_bucket_arn} and then i get an error of │ No module call named "s3_bucket_id" is declared in the root module. |
@dhmistry3 Could you create an issue for this with a reproducible example so that I can take a look? |
@DanielMSchmidt So it worked in the simplified version i made (https://github.com/dhmistry3/cdktf-cross-stack) so there must be something wrong i am doing in my main code. Thanks, i'll ask if i have any more questions. |
I'm going to lock this pull request because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Closes #651
General
This PR adds support for cross stack references (initially for the local and Terraform Cloud backend being used in the source stack).
A Cross Stack Reference is a reference that is used in a different stack than it's created, e.g.:
How to review
I'd recommend going commmit by commit, they should all make sense by themselves