-
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
Unable to set child tags when parent tags are inherited #1725
Unable to set child tags when parent tags are inherited #1725
Comments
A workaround is to use the
Perhaps this is "works as expected"? Its unclear from the documentation IMO. |
This is not the expected behavior. I think we have an issue with how tags are merged in L1s between the tags supplied in props and TagManager. |
@moofish32 could you take a look? I wonder if this is related to #1717 |
@eladb - this is the mixing of property tags and aspect tags. I was trying to look at #1717 and my first place to check is this same issue. In the design I tried to draw our attention to this: #1451 (comment). @cbeattie-bsm can you try? class MyParentConstruct extends cdk.Construct {
constructor(scope: cdk.Construct, id: string) {
super(scope, id);
this.apply(new cdk.Tag('Foo', 'Bar'));
const child = new MyChildConstruct(this, 'Child');
child.apply(new cdk.Tag('Name', 'MyVpc'));
}
} @eladb I can go back and add the ability to merge tags. The code is a little ugly as we have multiple formats and we have a broad |
@moofish32 Your code snippet above works. If you use |
@cbeattie-bsm - yes right now the two do not merge. If there is an
|
I think I would expect order of operations to apply. I would assume that internally we treat tags like a set so if there was a 'collision' my expectation would be that the tag value (and properties) would be overwritten.
I think my answer in question 1 (above) applies again here. My expectation would be that a subsequent tag operation would (or could) overwrite previous values. Taking a bit of a step back, let's look at a very practical use-case more mixing and matching these approaches to tags. In my case, I have a bunch of common tags that I want to set on all children of a construct (note: the parent/child tag inheritance is a GREAT feature). However, I want to set the "Name" tag individually on child items (for obvious reasons setting the "Name" tag at the parent scope doesn't make sense). I could simply use the |
This modifies the behavior of TagManager to enable the merging of tags provided during Cfn* properties with tag aspects. If a collision occurs the aspects tag precedence. fixes aws#1725
This modifies the behavior of TagManager to enable the merging of tags provided during Cfn* properties with tag aspects. If a collision occurs the aspects tag precedence. Fixes #1725
It seems when you apply tags at a parent scope, any additional tags set on a child will not be set.
Results:
I would expect that the child object would have both a 'Foo' and 'Name' tag.
The text was updated successfully, but these errors were encountered: