Skip to content
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

aws_cdk.triggers: When using a CDK stack containing a trigger, an exception is thrown if a tag is added from a SSM parameter. #28072

Closed
sheridansmall opened this issue Nov 20, 2023 · 3 comments
Labels
@aws-cdk/core Related to core CDK functionality @aws-cdk/triggers Related to the triggers package bug This issue is a bug. effort/medium Medium work item – several days of effort needs-review p1

Comments

@sheridansmall
Copy link

sheridansmall commented Nov 20, 2023

Describe the bug

When using a CDK stack containing a trigger, an exception is thrown if a tag is added from a SSM parameter.

The exception is:

CdkBugStack | 3/8 | 11:21:30 | CREATE_FAILED | AWS::IAM::Role | AWSCDK.TriggerCustomResourceProviderCustomResourceProvider/Role (AWSCDKTriggerCustomResourceProviderCustomResourceProviderRoleE18FAF0A) Resource handler returned message: "1 validation error detected: Value '${Token[TOKEN.15]}' at 'tags.1.member.value' failed to satisfy constraint: Member must satisfy regular expression pattern: [\p{L}\p{Z}\p{N}_.:/=+-@]* (Service: Iam, Status Code: 400, Request ID: c8c9ca37-592a-4e87-b7a1-5a0a5a7cd750)" (RequestToken: 22ce585d-ad32-1183-9110-e92c209c6d32, HandlerErrorCode: GeneralServiceException)

Expected Behavior

I would expect the stack to deploy with all resources tagged with the tag

Current Behavior

An exception is thrown

Failed resources:
CdkBugStack | 11:21:30 | CREATE_FAILED | AWS::IAM::Role | AWSCDK.TriggerCustomResourceProviderCustomResourceProvider/Role (AWSCDKTriggerCustomResourceProviderCustomResourceProviderRoleE18FAF0A) Resource handler returned message: "1 validation error detected: Value '${Token[TOKEN.15]}' at 'tags.1.member.value' failed to satisfy constraint: Member must satisfy regular expression pattern: [\p{L}\p{Z}\p{N}_.:/=+-@]* (Service: Iam, Status Code: 400, Request ID: c8c9ca37-592a-4e87-b7a1-5a0a5a7cd750)" (RequestToken: 22ce585d-ad32-1183-9110-e92c209c6d32, HandlerErrorCode: GeneralServiceException)

❌ CdkBugStack failed: Error: The stack named CdkBugStack failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Resource handler returned message: "1 validation error detected: Value '${Token[TOKEN.15]}' at 'tags.1.member.value' failed to satisfy constraint: Member must satisfy regular expression pattern: [\p{L}\p{Z}\p{N}_.:/=+-@]* (Service: Iam, Status Code: 400, Request ID: c8c9ca37-592a-4e87-b7a1-5a0a5a7cd750)" (RequestToken: 22ce585d-ad32-1183-9110-e92c209c6d32, HandlerErrorCode: GeneralServiceException)
at FullCloudFormationDeployment.monitorDeployment (C:\NVM\v18.16.0\node_modules\aws-cdk\lib\index.js:471:10232)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.deployStack2 [as deployStack] (C:\NVM\v18.16.0\node_modules\aws-cdk\lib\index.js:474:180228)
at async C:\NVM\v18.16.0\node_modules\aws-cdk\lib\index.js:474:163476

❌ Deployment failed: Error: The stack named CdkBugStack failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Resource handler returned message: "1 validation error detected: Value '${Token[TOKEN.15]}' at 'tags.1.member.value' failed to satisfy constraint: Member must satisfy regular expression pattern: [\p{L}\p{Z}\p{N}_.:/=+-@]* (Service: Iam, Status Code: 400, Request ID: c8c9ca37-592a-4e87-b7a1-5a0a5a7cd750)" (RequestToken: 22ce585d-ad32-1183-9110-e92c209c6d32, HandlerErrorCode: GeneralServiceException)
at FullCloudFormationDeployment.monitorDeployment (C:\NVM\v18.16.0\node_modules\aws-cdk\lib\index.js:471:10232)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.deployStack2 [as deployStack] (C:\NVM\v18.16.0\node_modules\aws-cdk\lib\index.js:474:180228)
at async C:\NVM\v18.16.0\node_modules\aws-cdk\lib\index.js:474:163476

The stack named CdkBugStack failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Resource handler returned message: "1 validation error detected: Value '${Token[TOKEN.15]}' at 'tags.1.member.value' failed to satisfy constraint: Member must satisfy regular expression pattern: [\p{L}\p{Z}\p{N}_.:/=+-@]* (Service: Iam, Status Code: 400, Request ID: c8c9ca37-592a-4e87-b7a1-5a0a5a7cd750)" (RequestToken: 22ce585d-ad32-1183-9110-e92c209c6d32, HandlerErrorCode: GeneralServiceException)

Reproduction Steps

Deploy the stack:

    def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
        super().__init__(scope, construct_id, **kwargs)

        tag_value = aws_ssm.StringParameter.from_string_parameter_attributes(
            self,
            "tag_value",
            parameter_name="/my_existing_param"
        ).string_value

        Tags.of(self).add("my_tag", tag_value)

        func = aws_lambda.Function(
            self,
            "MyFunction",
            handler="index.handler",
            runtime=aws_lambda.Runtime.NODEJS_18_X,
            code=aws_lambda.Code.from_inline("foo")
        )

        triggers.Trigger(
            self,
            "trigger",
            handler=func,
            timeout=Duration.minutes(10),
            invocation_type=triggers.InvocationType.EVENT
        )

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.105.0 (build 04cb52d)

Framework Version

No response

Node.js Version

v18.18.2

OS

Windows Linux

Language

Python

Language Version

Python 3.9.13

Other information

No response

@sheridansmall sheridansmall added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 20, 2023
@github-actions github-actions bot added the @aws-cdk/triggers Related to the triggers package label Nov 20, 2023
@pahud
Copy link
Contributor

pahud commented Nov 21, 2023

probably related to #28017

@pahud pahud added p1 needs-review effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Nov 21, 2023
@pahud pahud added the @aws-cdk/core Related to core CDK functionality label Apr 17, 2024
@rix0rrr
Copy link
Contributor

rix0rrr commented Oct 1, 2024

It shouldn't be about the trigger. This can never work. You can apply tags like this to the resources, but not to the stack.

@rix0rrr rix0rrr closed this as completed Oct 1, 2024
Copy link

github-actions bot commented Oct 1, 2024

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/core Related to core CDK functionality @aws-cdk/triggers Related to the triggers package bug This issue is a bug. effort/medium Medium work item – several days of effort needs-review p1
Projects
None yet
Development

No branches or pull requests

3 participants