【发布时间】:2020-11-12 03:26:59
【问题描述】:
我正在浏览documentation,他们在资源中有aws_vpc.main.cidr_block。我定义了不在文档中的资源,但出现以下错误。
Terraform - expected cidr_block to contain a valid Value, got: 0.0.0.0 with err: invalid CIDR address: 0.0.0.0
为什么无效?我想让入口所有源 IP 都能够达到 443。
文件 vpc.tf
resource "aws_vpc" "main" {
id = "vpc-0da86af9876e72d66c"
cidr_block = "0.0.0.0/0"
}
文件 test.tf
resource "aws_security_group" "allow_tls" {
name = "allow_tls"
description = "Allow TLS inbound traffic"
vpc_id = aws_vpc.main.id
ingress {
description = "TLS from VPC"
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = [aws_vpc.main.cidr_block]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags = {
Name = "allow_tls"
}
}
【问题讨论】:
标签: amazon-web-services terraform aws-security-group