Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Terraform: what's the difference between "tags" and "tags_all"?

Tags:

terraform

After upgrading terraform to 3.64.2, even though I haven't changed any code, terraform plan reminds me that it will replace tag with tag_all. what's the difference between tags and tags_all?

~ resource "aws_lb_listener" "frontend_http_tcp" {
        id                = "xxxxx"
      ~ tags              = {
          - "environment" = "production" -> null
          - "purpose"     = "onboarding-integration" -> null
          - "terraform"   = "true" -> null
        }
      ~ tags_all          = {
          - "environment" = "production"
          - "purpose"     = "onboarding-integration"
          - "terraform"   = "true"
        } -> (known after apply)
        # (4 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }
like image 597
Ryan Lyu Avatar asked Sep 09 '25 18:09

Ryan Lyu


1 Answers

In Terraform, you can define tags in top-level. tags_all is basically individual resource tags + top level tags

For example;

# Terraform 0.12 and later syntax
provider "aws" {
  # ... other configuration ...
  default_tags {
    tags = {
      Environment = "Production"
      Owner       = "Ops"
    }
  }
}

resource "aws_vpc" "example" {
  # ... other configuration ...

  # This configuration by default will internally combine tags defined
  # within the provider configuration block and those defined here
  tags = {
    Name = "MyVPC"
  }
}

In above example; tags_all will be

tags_all = {
  Name = "MyVPC"
  Environment = "Production"
  Owner       = "Ops"
     }

while tag is

tags = {
    Name = "MyVPC"
  }

Reference = https://registry.terraform.io/providers/hashicorp/aws/latest/docs/guides/resource-tagging

like image 131
Oguzhan Aygun Avatar answered Sep 13 '25 03:09

Oguzhan Aygun



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!