【问题标题】:terraform tag value with special characters带有特殊字符的 terraform 标签值
【发布时间】:2022-01-07 14:44:14
【问题描述】:

虽然尝试通过 Web 控制台更新 AWS 接受低于标记值,但是使用 terraform 很难完成任务。

我想针对我的资源更新的标签是:

1. "IT R&D & DATA - 7777"
2. "Example Team, Inc. - 001"

在 terraform 应用期间,每次不同的尝试都会出现以下错误(但预览始终显示正确的数据)。有什么解决方法吗?

Error: error updating LB (arn:aws:elasticloadbalancing:us-west-1:xxxx:loadbalancer/app/LB-DEV/f4c252) 
  tags: error tagging resource (arn:aws:elasticloadbalancing:us-west-1:xxxx:loadbalancer/app/LB-DEV/f4c252): 
  ValidationError: 1 validation error detected: Value 'Example Team, Inc. - 001' at 'tags.1.member.value' 
  failed to satisfy constraint: Member must satisfy regular expression pattern: ^([\p{L}\p{Z}\p{N}_.:/=+\-@]*)$
resource "aws_lb" "lb" {

    internal           = "true"
    load_balancer_type = "application"
    name               = format("%s%s","LB-",var.name)
    subnets            = data.aws_subnet_ids.subnet.ids
    security_groups    = [
        data.aws_security_group.sec_group.id
    ]

    tags = {
        business_unit       = "IT R//&D //& DATA //- 7777"
        legal_entity        = replace("Example Team, Inc. - 001", "/(['\\*])/", "//$1")
    }
}

【问题讨论】:

    标签: amazon-web-services terraform terraform-provider-aws


    【解决方案1】:

    & 不允许在标签中。来自docs

    一般来说,允许的字符是字母、数字、可以用 UTF-8 表示的空格,以及以下字符:_。 : / = + - @.

    【讨论】:

    • 抱歉回复晚了。甚至“,”也会产生问题,但如果您从网络上尝试它不会抱怨。我们仍在为网络上的所有资源更新带有逗号的标签。但是为了让 terraform 工作,我删除了 & 和 ","
    猜你喜欢
    • 2014-06-25
    • 2016-06-19
    • 2021-11-10
    • 1970-01-01
    • 2016-02-17
    • 2020-06-11
    • 2018-10-11
    • 2011-05-13
    • 1970-01-01
    相关资源
    最近更新 更多