target_groups 可选参数不是可选的:terraform
target_groups optional param is not optional : terraform
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"
}
}
我相信这个特定模块的目的是让您在指定 ingress_rules
和 egress_rules
时从 its table of predefined rules select。
在我写这篇文章时,我没有看到规则的定义 "http-3306-tcp"
,所以我认为这就是您出错的原因。如果您的意图是为 MySQL 允许 TCP 端口 3306,那么它的规则键似乎是 "mysql-tcp"
.
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"
}
}
我相信这个特定模块的目的是让您在指定 ingress_rules
和 egress_rules
时从 its table of predefined rules select。
在我写这篇文章时,我没有看到规则的定义 "http-3306-tcp"
,所以我认为这就是您出错的原因。如果您的意图是为 MySQL 允许 TCP 端口 3306,那么它的规则键似乎是 "mysql-tcp"
.