Amazon web services 目标组可选参数不是可选的:terraform
给定的键未标识此集合值中的元素Amazon web services 目标组可选参数不是可选的:terraform,amazon-web-services,terraform,hcl,Amazon Web Services,Terraform,Hcl,给定的键未标识此集合值中的元素 我完全不懂。我们需要帮助 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.ind
我完全不懂。我们需要帮助
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
我相信这个特定模块的目的是在指定
入口规则
和出口规则
时进行选择
在我写这篇文章的时候,我没有看到规则“http-3306-tcp”的定义,所以我认为这就是导致错误的原因。如果您的目的是允许MySQL使用TCP端口3306,那么这似乎是规则的关键。您可能需要向正在使用的第三方Terraform模块提交一个bug:或者深入源代码以找出问题所在。或者,您可以通过自己创建安全组而不是使用此模块来节省大量时间。我不认为使用这样的模块来执行这么小的任务有什么价值,特别是如果它有bug的话。
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"
}
}