https://pulumi.com logo
Title
g

great-sunset-355

07/27/2021, 3:47 AM
Is there a better way to auto-tag than maintaining the list of taggable resources? I'm mostly curious about multi-provider combinations, say AWS and Azure https://github.com/joeduffy/aws-tags-example/blob/master/autotag-py/taggable.py At the moment I add propagate the default tags from the config object and then add those to each resource explicitly. I've considered provider tags but this issue https://github.com/hashicorp/terraform-provider-aws/issues/19204 makes it unusable
l

little-cartoon-10569

07/27/2021, 4:11 AM
Not as far as I'm aware. There is no attribute that says a resource can or cannot have tags.
Though I suppose you could use introspection, since all the taggable resources have a
tags
property (at least in AWS). You'd need to be aware of the
tagsAll
property that some resources also have.
g

great-sunset-355

07/27/2021, 5:06 AM
hmm good point about
tagsAll
- do you have any example of such a resource? I wonder if it could have both arguments then?
l

little-cartoon-10569

07/27/2021, 5:23 AM
I think
tagsAll
is supposed to be a combination of
tags
and any tags that AWS gives the resource... I did come across a few resources with it, I'll have a quick hunt around for some.
VPCs and Directories both have tagsAll.
/**
     * A map of tags assigned to the resource, including those inherited from the provider .
     */
    readonly tagsAll: pulumi.Output<{
        [key: string]: string;
    }>;
g

great-sunset-355

07/27/2021, 5:38 AM
I'm quite confused from the description on what is the difference between
tags
and
tagsAll
`tagsAll`:
A map of tags assigned to the resource, including those inherited from the provider .
`tags`:
A map of tags to assign to the resource. .If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
I wonder what happens to
tagsAll
if they partially match
default_tags
from provider
p

proud-art-41399

07/27/2021, 7:17 AM
If you'd be interested in AWS with Python, check out https://github.com/tlinhart/pulumi-aws-tags It uses the
inspect
module to get the taggable resources.
g

great-sunset-355

07/27/2021, 7:49 AM
thanks @proud-art-41399 it looks great!