[英]terraform aws: Incorrect protocol in creating a security group
我有以下aws_security_group
我想用 terraform 实现:
resource "aws_security_group" "ort_to_db" {
name = "MySQL/AURORA"
vpc_id = data.aws_vpc.vpc_ort.id
ingress {
from_port = 3306
to_port = 3306
protocol = "MYSQL/Aurora"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = -1
cidr_blocks = ["0.0.0.0/0"]
}
}
但是,我在terraform apply
时收到以下错误:
错误:更新安全组入口规则:授权安全组(入口)规则:无效参数值:IP 协议的无效值“mysql/aurora”。 未知协议。 │
状态码:400,请求ID:d0
您查看的字段错误,协议类型为TCP
,而您查看的是Type
字段。 您可以在屏幕截图中看到它变灰并显示为 TCP。 文档也说明了这一点。 所以你需要解决这个问题:
resource "aws_security_group" "ort_to_db" {
name = "MySQL/AURORA"
vpc_id = data.aws_vpc.vpc_ort.id
ingress {
from_port = 3306
to_port = 3306
protocol = "TCP"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = -1
cidr_blocks = ["0.0.0.0/0"]
}
}
在文档中,查看Protocol type
列。
我认为 aws_security_group 只接受基本协议,例如 TCP 或 UDP...如果您使用的是 MySQL,则只需使用 TCP,因为这就是 MySQL 使用的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.