Terraform:"tags" 和 "tags_all" 有什么区别?
Terraform: what's the difference between "tags" and "tags_all"?
将 Terraform 升级到 3.64.2
后,即使我没有更改任何代码,terraform plan
提醒我它将 tag
替换为 tag_all
。 tags
和 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)
}
在 Terraform 中,您可以在 top-level 中定义标签。 tags_all
基本上是 individual resource tags
+ top level tags
例如;
# 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"
}
}
在上面的例子中; tags_all
将是
tags_all = {
Name = "MyVPC"
Environment = "Production"
Owner = "Ops"
}
标签是
tags = {
Name = "MyVPC"
}
参考=https://registry.terraform.io/providers/hashicorp/aws/latest/docs/guides/resource-tagging
将 Terraform 升级到 3.64.2
后,即使我没有更改任何代码,terraform plan
提醒我它将 tag
替换为 tag_all
。 tags
和 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)
}
在 Terraform 中,您可以在 top-level 中定义标签。 tags_all
基本上是 individual resource tags
+ top level tags
例如;
# 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"
}
}
在上面的例子中; tags_all
将是
tags_all = {
Name = "MyVPC"
Environment = "Production"
Owner = "Ops"
}
标签是
tags = {
Name = "MyVPC"
}
参考=https://registry.terraform.io/providers/hashicorp/aws/latest/docs/guides/resource-tagging