https://pulumi.com logo
#golang
Title
# golang
s

salmon-account-74572

07/02/2020, 8:46 PM
I'd like to define a set of tags that are applied to all resources, but still have additional tags that are defined per-resource. What's the best way to do that in Go?
b

billowy-army-68599

07/02/2020, 9:11 PM
I've had some success here with mergo https://github.com/imdario/mergo
i last used it for kubernetes labels, but the same thing should apply, something like this
Copy code
tags := pulumi.StringMap{
  "app": pulumi.String(name),
}

additionalTags := pulumi.StringMap{
  "owner": pulumi.String(owner)
}

if err := mergo.Merge(&tags, additionalTags, mergo.WithOverride); err != nil {
  if err != nil {
    return nil, err
  }
}
l

lemon-agent-27707

07/02/2020, 10:31 PM
Have you seen this article on tagging with transformations? https://www.pulumi.com/blog/automatically-enforcing-aws-resource-tagging-policies/
s

salmon-account-74572

07/02/2020, 10:40 PM
I have, thanks. It's a bit of overkill for my use case (single user, not a team of folks), I think.
14 Views