-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Trigger: Token strings not resolving #28017
Trigger: Token strings not resolving #28017
Comments
Yes I can reproduce this but can't find the root cause off the top of my head. We'll review this issue in the next few days. |
I get the same issue adding the parameter |
Any updates on this issue version 2.137 Member must satisfy regular expression pattern: CREATE_FAILED | AWS::IAM::Role | Custom::S3AutoDeleteObjectsCustomResourceProvider/Role (CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092) Resource handler returned message: "1 validation error detected: Value '${Token[AWS.Region.11]}' at 'tags.3.member.value' failed to satisfy constraint: Member must satisfy regular expression pattern: [\p{L}\p{Z}\p{N}_.:/=+-@]* (Service: Iam, Status Code: 400, ...) |
This is not an issue with triggers, it's a duplicate of #29424. The culprit is
The |
You can reference the SSM parameter value in a tag if you apply it at the construct level, and not on the stack itself. |
We also can't throw an error here, because users could have unresolved stack tags on stacks that have resources that happen to allow unresolved tokens. |
The behavior of stack tags is undesirable. Let's fix it. |
Stacks are considered taggable, and so `Tags.of(this).add('key', 'value')` used to add tags to Stacks in scope. Usually this happens if `this` is an instance of `Stack`, which it commonly is in user code. Since `Tags.of(...)` walks the construct tree, it will add tags to the stack *and* to all the resources in the stack. Then, come deploy time, CloudFormation will also try and apply all the stack tags to the resources again. This is silly and unnecessary. In #28017, someone tries to use a CloudFormation intrisinc in a tag applied using `Tags.of(this)`; that will work for resources as the tags are rendered into the template, but it will not work for the stack tags as those are passed via an API call, and intrinsics don't work there. IN THIS CHANGE The *correct* solution to tagging all resources with an intrinsic would be to tag each of them individually, as tagging a Stack with an intrinsic is not possible. That's a poor user experience. Resolve both the silly duplicate work as well as the "tagging with an intrinsic" use case as follows: - Stacks no longer participate in the hierarchical `Tags.of(...)` tagging. - Instead, only tags explicitly applied at the stack level (using the `tags` constructor property) are renderd as stack tags. This requires a user to make a conscious decision between resource-level and stack-level tagging: either apply tags to the stack, which will apply it to all resources; or apply tags to (groups of) resources inside the template.
Stack tags are not rendered to the template, but instead are passed via API call. Verify that stack tags do not contain unresolved values, as they won't work. Closes #28017.
Comments on closed issues and PRs are hard for our team to see. |
1 similar comment
Comments on closed issues and PRs are hard for our team to see. |
Describe the bug
Hi Team,
Just opening this ticket where the "Token" strings are not resolving during deployment and stays as "Token" strings
${Token[TOKEN.664]}
. This results in the error below:The error above is thrown against the "AWS::IAM::Role" which the
Trigger
construct creates because the value of its tag is a token string${Token[TOKEN.664]}
which did not resolve during deployment and is not a valid value for a Tag.For context, the setup here is that stack-level tags are being applied to the resources in the CDK stack (see code below) where its Tag value is retrieved from a resolvable token SSM parameter.
The value of these tags come from an SSM parameter
stringValue
which is a resolvable token. This error seems to occur when creating the IAM role that the parent constructTrigger
creates:Comparing this with a similar parent construct
AwsCustomResource
, the token strings are resolving during deployment and the tags are appropriately propagating to its child resources (AWS::IAM::Role, AWS::Lambda::Function).Hence, I'm presuming there is an issue with the
Trigger
construct such that token strings passed to its child resources are not resolving during deployment. I also noticed within the template that the "Tags" are not propagating to the child resources (Role, Lambda Function) during synthesis when compared toAwsCustomResources
where "Tags" are visible in the synthesized template.I also did some additional testing and this time just passing tag values as a simple string instead of SSM parameters and the deployment went through for
Trigger
and propagated the tags to the child resources but this wasn't still visible in the template.Are you able to give me an idea to why this happens, perhaps there is a gap with the
Trigger
construct? Is this a bug?Expected Behavior
Token strings of stack-level tags applied on child resources of Trigger not resolved during deployment
Current Behavior
Token strings of stack-level tags applied on child resources of Trigger to be resolved during deployment
Reproduction Steps
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.88.0
Framework Version
No response
Node.js Version
v18.7.0
OS
Windows
Language
TypeScript
Language Version
TypeScript
Other information
No response
The text was updated successfully, but these errors were encountered: