Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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(cdk): transparent cross-stack references #1436
feat(cdk): transparent cross-stack references #1436
Changes from all commits
7b97ebb
1f938cf
929b003
d02e16d
ac062fc
935fd82
9f40aa2
c1d4dc1
5d85318
4219539
d8876bf
0a724b4
445805f
cc928f8
3cb539f
0840d76
73353c0
f161a4d
7a105e9
ba3a4db
8093361
6330ab5
2c224c4
b17d811
a8e00d9
eef74a5
5978c6b
996f998
e0ec521
3a0d5b5
1d5388d
3ee48f7
d1b3c22
85cc4d2
8e64bc2
5694b9c
d1a643e
12854e6
c7d4314
d2a656f
fdeaa55
00cbe07
0346946
34bfb34
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 am wondering if it would make sense to only expose
resolve
during prepare and synthesis by passing in something likeSynthesisContext
to theprepare
method? This will sure people don't abuse this capability before the tree is ready.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.
That's interesting - /me likey.
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.
Are we prepared to have unresolved tokens in error messages?
https://github.com/awslabs/aws-cdk/blob/3a0d5b5cf98e3cbcbd6139ef1e07135b4bece5f7/packages/@aws-cdk/aws-kms/lib/key.ts#L71
https://github.com/awslabs/aws-cdk/blob/3a0d5b5cf98e3cbcbd6139ef1e07135b4bece5f7/packages/@aws-cdk/aws-lambda/lib/lambda-ref.ts#L419
Not entirely clear how this should work if it can't resolve:
https://github.com/awslabs/aws-cdk/blob/3a0d5b5cf98e3cbcbd6139ef1e07135b4bece5f7/packages/@aws-cdk/aws-s3/lib/util.ts#L35
The lazy arguments to
Token
will need to take theSynthesisContext
as an argument as well so they can resolve or JSONify inner structures:https://github.com/awslabs/aws-cdk/blob/3a0d5b5cf98e3cbcbd6139ef1e07135b4bece5f7/packages/@aws-cdk/aws-ecr/lib/repository.ts#L129
https://github.com/awslabs/aws-cdk/blob/3a0d5b5cf98e3cbcbd6139ef1e07135b4bece5f7/packages/@aws-cdk/aws-logs/lib/cross-account-destination.ts#L98
All still in favor?
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 thanks for the due diligence. It's so much nicer to have these discussions over actual examples.
Let's punt this change for now for the sake of progress, but I think we should still explore this. The examples you provided are interesting and actually expose some issues, which is precisely
Error messages: the practice of
JSON.stringify(resolve)
feels like a lucky hack anyway, and only works when specific construct authors are aware that a value might be a token. I think a more robust solution to this problem would be to improve the string representation of tokens of resource references (GetAtt/Refs) in strings so they will be less intimidating. For instance, one can argue that something like${{ "Fn::GetAtt": [ Logical, "Attribute" ]}}
can be used for GetAtt tokens (and this can be used as the map key to the token object.I'd argue that this use case should actually query
unresolved
and then just type-check. There is no need to actually resolve the values:https://github.com/awslabs/aws-cdk/blob/3a0d5b5cf98e3cbcbd6139ef1e07135b4bece5f7/packages/@aws-cdk/aws-s3/lib/util.ts#L35
this.node.onSynthesize(synthesisContext => bla)
, so yes, passingsynthesisContext
to such a lazy handler makes total sense to me.