dynamic block: リソース内の同名blockのループ

variable "sg_ssh_ingress" {
  default = [
    {
      cidr_blocks = ["xxx.xxx.xxx.xxx/32"]
      description = "ssh from AAA"
      security_groups = []
      self        = false
    },
    {
      cidr_blocks = ["xxx.xxx.xxx.xxx/32"]
      description = "ssh from BBB"
      security_groups = []
      self        = false
    },
...
  ]
}

resource "aws_security_group" "bastion" {
...
  dynamic "ingress" {
    for_each = var.sg_ssh_ingress
    content {
      from_port       = 22
      to_port         = 22
      protocol        = "tcp"
      cidr_blocks     = ingress.value.cidr_blocks
      security_groups = ingress.value.security_groups
      description     = ingress.value.description
      self            = ingress.value.self
    }
  }
...
}

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2025-06-02 (月) 18:12:57