Cloudformation does not tag resources

0

Hello, I am trying to figure out which tags does my CloudFront distribution have (for cost analysis). I am using Cloudformation to deploy the distribution, therefore I expected for distribution to have preconfigured the tags which cloud formation adds automatically (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html).

When checking the tags, I only see "stage" tag.

Why are the tags not added to CloudFront distribution?

PS: I have noticed similar behavior for API gateways as well.

2 Answers
0

[Edited] Hi!

The only CLI command to list tags for a CloudFront resource is the command you used list-tags-for-resource : https://docs.aws.amazon.com/cli/latest/reference/cloudfront/list-tags-for-resource.html.

The Max Retries error you see comes from AWS's CLI - there are maximum numbers of retries built in: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-retries.html

If you are looking for the tags:

  • aws:cloudformation:logical-id
  • aws:cloudformation:stack-id
  • aws:cloudformation:stack-name

These 3 tags are only added at the CloudFormation stack level and you're right - should be propogated to resources that CloudFormation supports (except for right now, EBS volumes).

If you add more resource tags at the CloudFormation level, for example "project" : "Project ABC", that tag will propagate down to resources supported by CFT. In your case, if you are using CloudFormation (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_CloudFront.html), the AWS::CloudFront::Distribution resource.

I would suggest adding a new tag such as "project": "Project ABC" to help with cost attribution. Have you tried that on the CloudFormation stack to see if they propogate? If that doesn't work, interesting find that the tags aren't propagating properly.

jsonc
answered 2 years ago
  • I am not sure you are completely correct about tagging.

    According to the documentation (link I posted above) :

    All stack-level tags, including automatically created tags, are propagated to resources that CloudFormation supports.

    Also, I am seeing mixed behavior for various resources. When creating lambda the

    • aws:cloudformation:logical-id
    • aws:cloudformation:stack-id
    • aws:cloudformation:stack-name

    are added automatically. When creating Cloudfront distribution I am getting tags that I specify on stack level (during CREATE/UPDATE), but not the aforementioned tags.

  • You're right - I modified the response above. I wonder if it's a bug on the aws:cloudformation:<value> tags.

0

I think that there is only stage tag then.

For me, CLI command and AWS console shows exactly the same tags :)

One pro tip, never show your AWS Account Id publicly as you did in the CLI command.

profile picture
MG
answered 2 years ago
  • Ok, I have fixed the problem with CLI (I accidentally used the wrong profile).

    Anyways question still is: Why does Cloudformation does not propagate the tags it should

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions