【问题标题】:Default Tags using ECS Service使用 ECS 服务的默认标签
【发布时间】: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 标记?

【问题讨论】:

    标签: terraform-provider-aws


    【解决方案1】:

    您应该能够使用带有 ignore_changes 的生命周期块来排除任何外部更改。我不确定这是否可行。不过你可以试试。

    【讨论】:

    • 我试过了。它将排除对现有标签的更改,但此时没有设置标签。
    猜你喜欢
    • 2019-05-05
    • 1970-01-01
    • 2023-03-04
    • 1970-01-01
    • 2020-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-14
    相关资源
    最近更新 更多