【问题标题】:Can you tag inbound Name on inbound rules on an AWS security group using terraform?您可以使用 terraform 在 AWS 安全组的入站规则上标记入站名称吗?
【发布时间】:2021-11-17 12:13:16
【问题描述】:

我正在尝试为我的安全组中的每个条目设置单独的名称。

我的示例代码在下面不起作用,我希望这会在图片中产生结果,但名称标签保持空白(我通过控制台将此设置为图片中的示例)。此标签适用于其他地方,例如针对安全组的“Allow-Google”名称标签。有什么方法可以实现吗?

resource "aws_security_group" "allow-google-dns" {
  name        = "allow-google-dns"
  description = "Allows google dns"
  vpc_id      = var.vpcid

  ingress = [
    {
      description      = "allows google in"
      from_port        = 0
      to_port          = 0
      protocol         = "-1"
      cidr_blocks = ["8.8.8.8/32" ]
      ipv6_cidr_blocks = []
      prefix_list_ids = []
      security_groups = []
      self = false
      tags = {
    Name = "MyName"
           }
    }
  ]

  tags = {
    Name = "Allow-Google"
  }
}

AWS Console

【问题讨论】:

  • 太新了,TF还不支持。

标签: terraform terraform-provider-aws


【解决方案1】:

Marcin 是对的(暂时)。

从带有 AWS 提供程序 3.60.0 版本的 Terraform 1.0.7 开始,不支持标记规则,无论是内联格式还是外部 aws_security_group_rule 资源。

但是 Terraform 不会注意到任何已放置的标签,因此您可以想象在创建后添加它们,并且 Terraform 不会在您重新应用时将其检测为更改。

【讨论】:

    猜你喜欢
    • 2019-12-14
    • 1970-01-01
    • 1970-01-01
    • 2021-08-16
    • 2022-01-22
    • 2017-08-10
    • 1970-01-01
    • 2017-03-16
    • 2021-08-10
    相关资源
    最近更新 更多