首页 > 解决方案 > 我在进行 terragrunt apply 时收到 CIDR 错误

问题描述

模块/sg 内的 main.tf

  //vpc_id = var.vpc_id

  //all inbound traffic
  ingress {
    from_port   = "22" //opens tcp 22 port for ssh
    to_port     = "22"
    protocol    = "tcp"
    cidr_blocks = [var.trusted_ip_ingress]
  }
}

模块/sg 内的 variable.tf

variable "trusted_ip_ingress" {}

terragrunt.hcl

  source = "./../../../modules//sg"
}

inputs = {
  trusted_ip_ingress = ["0.0.0.0/0"]
}

请在执行 terragrunt plan 时找到错误 在执行 terragrunt plan 时出现错误消息

标签: amazon-web-servicesterraformaws-security-groupterragrunt

解决方案


trusted_ip_ingress的已经是一个列表。所以你应该使用:

  ingress {
    from_port   = "22" //opens tcp 22 port for ssh
    to_port     = "22"
    protocol    = "tcp"
    cidr_blocks =  var.trusted_ip_ingress
  }

推荐阅读