Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define default tags with pulumi aws provider

What is the correct way to define default tags so that they are applied to all AWS resources in my stack? I have the following provider config, but none of my resources are actually tagged:

config:
  aws:defaultTags:
    tags:
      key1: value1
      key2: value2
  aws:region: us-west-1

Versions:

@pulumi/[email protected]
@pulumi/[email protected]
like image 484
stelmod Avatar asked Oct 24 '25 04:10

stelmod


2 Answers

Answering my own question after a few hours of trial and error. Based on the sample config in the question:

  • Default tags are applied to new resources
  • Default tags are applied to resources that are being updated
  • Default tags are NOT automatically applied to all existing resources
  • Default tags do NOT show up in any scenario during pulumi preview --diff
like image 183
stelmod Avatar answered Oct 26 '25 20:10

stelmod


This policy pack is configurable so that you can enforce arbitrary tags without needing to change the pack’s code, making it reusable. For the CLI scenario, we will create a policy-config.json file that specifies the same three required tags shown above:

    {
    "all": "mandatory",
    "check-required-tags": {
        "requiredTags": [
            "user:Project",
            "user:Stack",
            "user:Cost Center"
        ]
    }
}

Default tags

tags
{[key: string]: string}

read more- https://www.pulumi.com/blog/automatically-enforcing-aws-resource-tagging-policies/

like image 22
Learn2Skills Avatar answered Oct 26 '25 19:10

Learn2Skills



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!