Skip to content

Stack: Tag propagation #33945

Open
Open
@YuriGal

Description

@YuriGal

Describe the bug

When Tags are applied at a stack level - they propagate to all children, which is fine, but in some case some children must be excluded. E.g. some resources may not be taggable in Govcloud, attempt to tag them will throw an exception. Or adding tags will force resource to delete an re-create, which is not desirable.

Using props excludeResourceTypes while adding tags, or includeResaourceTypes while removing has no effect when applied at stack level. Neither does addPropertyDeletionOverride('Tags') at the resource level. By "no effect" I mean tags are removed from the resource in synthesized template, but will still appear in the deployed resource.

Is there any way to skip some resources from being tagged when tags are applied at the stack level?

Regression Issue

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

Last Known Working CDK Version

2.178.1

Expected Behavior

Specified resource should not be tagged when tags are applied at stack level.

Current Behavior

All stack's resources are tagged when tags are applied at stack level.

Reproduction Steps

Try something like

Tags.of(stack).add('key', 'value, {
      excludeResourceTypes: ['AWS::S3::Bucket']
 });

on a stack that has buckets. Tag will be applied anyway.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.178.1 (build ae342cb)

Framework Version

No response

Node.js Version

v20.12.2

OS

MacOS Sonoma 14.7.3

Language

TypeScript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.effort/mediumMedium work item – several days of effortp1package/toolsRelated to AWS CDK Tools or CLI

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions