aws-tags-example icon indicating copy to clipboard operation
aws-tags-example copied to clipboard

Simplify `auto_tag`

Open yellowhat opened this issue 4 years ago • 6 comments

Hi, I would like to propose to simplify the auto_tag function to this:

def auto_tag(args, auto_tags):
    """ Applies the given tags to the resource properties if applicable. """

    if hasattr(args.resource, "tags"):
        args.props["tags"] = {**(args.props["tags"] or {}), **auto_tags}
        return pulumi.ResourceTransformationResult(args.props, args.opts)

in order to remove the dependency on taggable.py and all the static definition of taggable resources. I have tested using Azure, so it would be great if someone can test it on AWS.

Thanks

yellowhat avatar Apr 16 '21 12:04 yellowhat

In Go I went this way instead of the isTaggable function and so far that works - granted not tested all resource types

if !val.FieldByName("Tags").CanSet() {
...
}

universam1 avatar May 12 '21 15:05 universam1

@yellowhat this is perfect, works and using on AWS!!! 🎉

bryantbiggs avatar Jun 03 '21 15:06 bryantbiggs

The only problem I have run into so far in AWS with python is with: https://www.pulumi.com/registry/packages/aws/api-docs/autoscaling/group/#tags_python

The tag property for the autoscaling group wants Sequence[GroupTagArgs] which causes this to method to fail.

jamie1911 avatar Jan 24 '22 21:01 jamie1911

This is awesome and works on AWS with Python for us! Haven't run into any issues so far. 🙂

neelakansha85 avatar Apr 01 '22 15:04 neelakansha85

how to merge it with existing tags, for example Name tags

sai-caylent avatar Nov 18 '23 00:11 sai-caylent

It should work as it merges existing tags.

yellowhat avatar Nov 18 '23 06:11 yellowhat