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

AwsCdkCli: Error occurred while deploying a stack that reads resource values from SSM in version 2.161.1 #31668

Open
1 task
cjnoname opened this issue Oct 5, 2024 · 7 comments
Labels
@aws-cdk/aws-ssm Related to AWS Systems Manager bug This issue is a bug. p3

Comments

@cjnoname
Copy link

cjnoname commented Oct 5, 2024

Describe the bug

Our CDK application is breaking. We're trying to add tags to all resources within the CloudFormation template by reading the values from the SSM Parameter Store. However, during deployment with the latest version, we're encountering the following error on the latest version:

Error: Stack tags may not contain deploy-time values (tag: awsApplication=${Token[TOKEN.16]}). Apply tags containing deploy-time values to resources only, avoid tagging stacks.

Our requirement is to add a tag from the SSM Parameter Store to all resources within the stack. Please either resolve this issue or provide an alternative solution to achieve this.

#31457

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

It should work.

Current Behavior

It does not work.

Reproduction Steps

Our requirement is to add a tag from the SSM Parameter Store to all resources within the stack. Please either resolve this issue or provide an alternative solution to achieve this, which doesn't work in version 2.161.1.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.161.1

Framework Version

No response

Node.js Version

22

OS

MacOS

Language

TypeScript

Language Version

No response

Other information

No response

@cjnoname cjnoname added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 5, 2024
@github-actions github-actions bot added the @aws-cdk/aws-ssm Related to AWS Systems Manager label Oct 5, 2024
@pahud
Copy link
Contributor

pahud commented Oct 6, 2024

Our requirement is to add a tag from the SSM Parameter Store to all resources within the stack. Please either resolve this issue or provide an alternative solution to achieve this, which doesn't work in version 2.161.1.

Are you able to provide minimal reproducible code snippets so we can quickly reproduce that in our environment?

And, did you mean this was previously working but broken in 2.161.1? If yes, what is the last known working CDK version?

@pahud pahud added p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Oct 6, 2024
@cjnoname
Copy link
Author

cjnoname commented Oct 6, 2024

Our requirement is to add a tag from the SSM Parameter Store to all resources within the stack. Please either resolve this issue or provide an alternative solution to achieve this, which doesn't work in version 2.161.1.

Are you able to provide minimal reproducible code snippets so we can quickly reproduce that in our environment?

And, did you mean this was previously working but broken in 2.161.1? If yes, what is the last known working CDK version?

Hey mate,

it's all because of this commit:
#31457

To reproduce the issue is quite simple - add this line to any of the stacks:

Tags.of(stack).add(
  "anytag",
  StringParameter.valueForStringParameter(stack, `/app/anytag`)
);

Our requirement is to add a tag from the SSM Parameter Store to all resources within the stack. Please either resolve this issue or provide an alternative solution to achieve this.

@pahud
Copy link
Contributor

pahud commented Oct 6, 2024

Error: Stack tags may not contain deploy-time values (tag: awsApplication=${Token[TOKEN.16]}). Apply tags containing deploy-time values to resources only, avoid tagging stacks.

If you see this error, this is because #31457 fixed a bug and doesn't allow stack tags contain unresolved values.

Can you share your minimal code snippets to help us look into your issue?

@pahud pahud added p3 and removed p2 needs-triage This issue or PR still needs to be triaged. labels Oct 6, 2024
@cjnoname
Copy link
Author

cjnoname commented Oct 6, 2024

To reproduce the issue is quite simple - add this line to any of the stacks:

Tags.of(stack).add(
  "anytag",
  StringParameter.valueForStringParameter(stack, `/app/anytag`)
);

Our requirement is to add a tag from the SSM Parameter Store to all resources within the stack. Please either resolve this issue or provide an alternative solution to achieve this.

To reproduce the issue is quite simple - add this line to any of the stacks:

Tags.of(stack).add(
"anytag",
StringParameter.valueForStringParameter(stack, /app/anytag)
);
Our requirement is to add a tag from the SSM Parameter Store to all resources within the stack. Please either resolve this issue or provide an alternative solution to achieve this.

To be honest, I understand that the commit is intended to prevent the generation of incorrect tags in the CloudFormation stack, such as "Tokenxxxx." However, I don't understand why it restricts normal usage. I only want to add the tag once at the stack level, rather than needing to add it 100 times for each resource.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Oct 11, 2024
@SeijiSuenaga
Copy link

SeijiSuenaga commented Oct 11, 2024

I'm encountering the same error using versions 2.161.0 through 2.162.1 (currently latest) when trying to use a stack parameter in a stack tag. Previously, applying the tag at the stack level like this (using .NET CDK):

var stackParameter = new CfnParameter(this, "StackParameter", new CfnParameterProps
{
    Description = "Example",
    Type = "String",
});

Tags.Of(this).Add("ExampleTag", stackParameter.ValueAsString);

would apply it to each resource within the stack like this:

{
  "Key": "ExampleTag",
  "Value": {
    "Ref": "StackParameter"
  }
},

And the resulting tags had the correct value upon deployment, so I'm not sure why this was considered a bug and is now rejected:

Unhandled exception. System.Exception: Error: Stack tags may not contain deploy-time values (tag: ExampleTag=${Token[TOKEN.18]}). Apply tags containing deploy-time values to resources only, avoid tagging stacks.

@cjnoname
Copy link
Author

@rix0rrr Can you please help on this?

@cjnoname
Copy link
Author

Our requirement is to add a tag from the SSM Parameter Store to all resources within the stack. Please either resolve this issue or provide an alternative solution to achieve this, which doesn't work in version 2.161.1.

Are you able to provide minimal reproducible code snippets so we can quickly reproduce that in our environment?

And, did you mean this was previously working but broken in 2.161.1? If yes, what is the last known working CDK version?

If there's no plan to fix this issue in short, could you please help to rollback this commit?

#31457

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ssm Related to AWS Systems Manager bug This issue is a bug. p3
Projects
None yet
Development

No branches or pull requests

3 participants