I am using cdk Aspects and I can see that the statement is being printed out from the visit method. However, when I try to add a Tag to each resource within my stack, nothing happens.
This is the line I have in my app.py.
cdk.Aspects.of(my_stack).add(TagsAddingAspect())
This is my aspect.py class.
import jsii
from aws_cdk import (
IAspect, Tag, Tags
)
@jsii.implements(IAspect)
class TagsAddingAspect:
def visit(self, node):
print(f'{node.node.path} - {node.__class__.__name__}') # This gets printed so I know am definitely hitting the visit function for each resource.
#Tags.of(node).add('aspect_test_tag', 'tag1')
Tag('aspect_test_tag', 'tag1').visit(node)
I tried both options above to create a tag, but neither resulted in the tags being created in the stacks resources. The documentation indicates that either should work.
https://docs.aws.amazon.com/cdk/v2/guide/tagging.html
There may be a gap in my understanding… If someone could point me in the right direction, I’d appreciate it! Thanks.
3