Jos*_*rán 7 terraform terraform-provider-aws terraform0.12+
我正在学习 Terraform 和 AWS,但在创建资源时遇到了麻烦aws_security_group。
我从Terraform 文档复制了此资源的示例,然后配置了我的数据(我想通过 SSH 访问我的 EC2 资源。我知道这不是一个好的做法,但我只是在学习,我会测试后销毁)
\nresource "aws_security_group" "allow_tls_ssh" {\n name = "allow_tls"\n description = "Allow TLS inbound traffic"\n vpc_id = aws_vpc.vpc.id\n\n ingress = [\n {\n description = "TLS from VPC"\n from_port = 443\n to_port = 443\n protocol = "tcp"\n cidr_blocks = [aws_vpc.vpc.cidr_block]\n ipv6_cidr_blocks = [aws_vpc.vpc.ipv6_cidr_block]\n prefix_list_ids = []\n security_groups = []\n self = false\n },\n {\n description = "SSH from VPC"\n from_port = 22\n to_port = 22\n protocol = "tcp"\n cidr_blocks = [aws_vpc.vpc.cidr_block]\n ipv6_cidr_blocks = [aws_vpc.vpc.ipv6_cidr_block]\n prefix_list_ids = []\n security_groups = []\n self = false\n },\n {\n description = "HTTP from VPC"\n from_port = 80\n to_port = 80\n protocol = "tcp"\n cidr_blocks = [aws_vpc.vpc.cidr_block]\n ipv6_cidr_blocks = [aws_vpc.vpc.ipv6_cidr_block]\n prefix_list_ids = []\n security_groups = []\n self = false\n }\n ]\n\n tags = {\n Name = "allow_tls_ssh"\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n然后,当我terraform apply得到:
\n(...)\n\n\xe2\x94\x82 59: }\n\xe2\x94\x82 60: ]\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\n\xe2\x94\x82 \xe2\x94\x82 aws_vpc.vpc.cidr_block will be known only after apply\n\xe2\x94\x82 \xe2\x94\x82 aws_vpc.vpc.ipv6_cidr_block will be known only after apply\n\xe2\x94\x82 \n\xe2\x94\x82 Inappropriate value for attribute "ingress": element 0: attributes "prefix_list_ids", "security_groups", and "self" are required.\n\xe2\x95\xb5\nRun Code Online (Sandbox Code Playgroud)\n这个错误让我很困惑。为什么我在创建安全组时必须指定 security_groups?
\n| 归档时间: |
|
| 查看次数: |
2587 次 |
| 最近记录: |