【发布时间】:2021-09-08 06:17:14
【问题描述】:
我们的大多数 ECS 服务都不是允许设置标签的“新”格式。
我们最近向我们的 aws 提供程序添加了默认标签,例如:
provider "aws" {
region = local.workspace["aws_region"]
profile = local.workspace["aws_profile"]
default_tags {
tags = {
Environment = local.workspace["releaseStage"]
Owner = "terraform"
Project = "infrastructure"
Account = local.workspace["releaseStage"]
}
}
}
但是,如果我们运行 terraform apply,它会在 ecs 服务资源上咆哮,因为它们不支持标记:
错误:更新 ECS 服务时出错 (arn:aws:ecs:us-east-1:xxxx:service/myservice) 标签:错误标记资源 (arn:aws:ecs:us-east-1:xxxx:service/ myservice): InvalidParameterException: Long arn 格式必须用于标记操作
如果我覆盖资源中的标签,例如:
resource "aws_ecs_service" "myservice" {
name = "myservice"
...
tags = {
Environment = ""
Owner = ""
Project = ""
Account = ""
}
}
它有效,但我从来没有得到一个干净的地形计划,因为它总是需要评估合并的标签。
有没有办法排除带有某些资源的 default_tags 标记?
【问题讨论】: