1
Error: Invalid index

  on .terraform/modules/database-security-group/main.tf line 70, in resource "aws_security_group_rule" "ingress_rules":
  70:   to_port   = var.rules[var.ingress_rules[count.index]][1]
    |----------------
    | count.index is 0
    | var.ingress_rules is list of string with 1 element
    | var.rules is map of list of string with 119 elements

给定键未标识此集合值中的元素

.


对我来说都是希腊语。我们可以使用帮助..

module "database-security-group" {
  source = "terraform-aws-modules/security-group/aws"
  name        = "database-security"
  description = "Security group for Database on database subnet."
  vpc_id      = module.vpc.vpc_id
  ingress_cidr_blocks = ["0.0.0.0/0"]
  ingress_rules       = [ "http-3306-tcp"]
  egress_rules        = ["all-all"]
  tags = {
    Name        = "Database"
    Environment = "spoon"
  }
}
4

1 回答 1

0

我相信这个特定模块的目的是您在指定and时从其预定义规则表中进行选择。ingress_rulesegress_rules

在我写这篇文章的时候,我没有看到规则的定义"http-3306-tcp",所以我认为这是你错误的原因。如果您的意图是允许 MySQL 使用 TCP 端口 3306,那么它的规则键似乎是"mysql-tcp".

于 2020-10-20T22:52:41.173 回答