我已经将我的第一个 terraform 脚本放在一起,用于在 AWS 上进行资产配置。但是,我无法连接到公有子网中的 EC2 实例
我可以看到所有预期的资源都已创建:子网/实例/路由表/网关等
我已经排除了 provider.tf,因为它包含敏感的秘密。
我的地区是 ap-south-1。
resource "aws_vpc" "vpc1" {
cidr_block = "10.20.0.0/16"
tags = {
name = "tf_vpc"
}
}
# subnets below
resource "aws_subnet" "subnet_public"{
vpc_id = "${aws_vpc.vpc1.id}"
cidr_block = "10.20.10.0/24"
availability_zone = "ap-south-1a"
map_public_ip_on_launch = true
}
resource "aws_subnet" "subnet_private"{
vpc_id = "${aws_vpc.vpc1.id}"
cidr_block = "10.20.20.0/24"
availability_zone = "ap-south-1a"
}
resource "aws_security_group" "sg-web" {
name ="allow80"
description="allows traffic on port 80"
vpc_id ="${aws_vpc.vpc1.id}"
ingress{
from_port = 80
to_port = 80
protocol …Run Code Online (Sandbox Code Playgroud)