-
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
(core/stack): stack.tags does not do anything #30055
Comments
This seems to work fine for me, did you only check the import { App, CfnOutput, Stack, type StackProps } from "aws-cdk-lib";
import { Bucket } from "aws-cdk-lib/aws-s3";
import { Topic } from "aws-cdk-lib/aws-sns";
import { Queue } from "aws-cdk-lib/aws-sqs";
import type { Construct } from "constructs";
const app = new App();
class TagsStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const bucket = new Bucket(this, "Bucket");
const queue = new Queue(this, "Queue");
const topic = new Topic(this, "Topic");
new CfnOutput(this, "BucketName", { value: bucket.bucketName });
new CfnOutput(this, "QueueUrl", { value: queue.queueUrl });
new CfnOutput(this, "TopicArn", { value: topic.topicArn });
}
}
new TagsStack(app, "TagsStack", {
tags: { TAG_KEY: "TAG_VALUE" },
}); $ yarn cdk deploy
Outputs:
TagsStack.BucketName = tagsstack-bucket83908e77-w8nobhqbuytq
TagsStack.QueueUrl = https://sqs.us-east-1.amazonaws.com/339712719728/TagsStack-Queue4A7E3555-TIfUha8OSg9G
TagsStack.TopicArn = arn:aws:sns:us-east-1:339712719728:TagsStack-TopicBFC7AF6E-5fd7L5n4nsPh
$ aws s3api get-bucket-tagging --bucket tagsstack-bucket83908e77-w8nobhqbuytq | jq '.TagSet[0]'
{
"Key": "TAG_KEY",
"Value": "TAG_VALUE"
}
$ aws sqs list-queue-tags --queue-url https://sqs.us-east-1.amazonaws.com/339712719728/TagsStack-Queue4A7E3555-TIfUha8OSg9G | jq '.Tags'
{
"TAG_KEY": "TAG_VALUE"
}
$ aws sns list-tags-for-resource --resource-arn arn:aws:sns:us-east-1:339712719728:TagsStack-TopicBFC7AF6E-5fd7L5n4nsPh | jq '.Tags[0]'
{
"Key": "TAG_KEY",
"Value": "TAG_VALUE"
} |
Hi That is stack-level tags and it would not show up in the synthesized template. Cloudformation would be responsible to propagate it to resources but please note:
see - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html We generally recommend using |
Thanks! Ask now would be to update the docs to better explain what stacks.tags does and how/link to other docs and that Tags.of would be preferred. |
Sure I am leaving this issue open as p3 and we welcome any PRs to update the doc. |
Describe the bug
Possible regression. Creating this for a customer and they had this working. Waiting on them to give me the cdk version where this was working.
stack.tags does not do anything. I spot checked 2.1.0, 2.50.0, 2.100.0 cdk version and I cannot see where it worked.
Expected Behavior
When specifing stack.tags it will go out and tag the constructs that support tagging.
Current Behavior
stack.tags seemingly does nothing.
Reproduction Steps
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.140.0
Framework Version
No response
Node.js Version
v18.17.1
OS
Ubuntu 22.04 - Linux
Language
TypeScript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: