resource "aws_internet_gateway" "tf_igw" { vpc_id = aws_vpc.tf_vpc.id tags = { Name = "tf-igw" } } 解释 resource "aws_internet_gateway" "tf_igw": 声明创建一个名为 tf_igw 的互联网网关资源。 vpc_id = aws_vpc.tf_vpc.id: 将此互联网网关与之前创建的虚拟私有云(VPC)关联。通过...
resource "aws_internet_gateway" "gw" { vpc_id = var.vpc_id tags = { Name = "Project VPC IG" }}resource "aws_route_table" "public" { vpc_id = var.vpc_id route { cidr_block = "0.0.0.0/0" gateway_id = aws_internet_gateway.gw.id } tags = { Name = "Public Route Table...
我们将继续使用 CLI 配置我们的 AWS 凭证。https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html 拥有必要的工具后,我们将继续克隆存储库。https://github.com/lguerraq/AWS-VPC 我们将使用 VSCode 打开克隆的文件夹。我们会将配置的配置文件的名称放在凭据文件 (/.aws/credentials) ...
cidr_block="10.0.0.0/24"tags=merge(local.common_tags,{Name="public-subnet"})}resource"aws_internet_gateway""project01-igw"{vpc_id=aws_vpc.project01-vpc.id tags=merge(local.common_tags,{Name="project01-igw"})}resource"aws_route_table""project01-rtb"{vpc_id=aws_vpc.project01-vpc.id ...
resource "aws_subnet" "public_subnets" { count = length(var.public_subnet_cidrs) vpc_id = aws_vpc.main.id cidr_block = element(var.public_subnet_cidrs, count.index) availability_zone = element(var.azs, count.index) tags = local.xuel_tag ...
resource "aws_route_table" "prod-public-crt" { vpc_id = aws_vpc.prod-vpc.id route { //associated subnet can reach everywhere cidr_block = "0.0.0.0/0" //CRT uses this IGW to reach internet gateway_id = aws_internet_gateway.prod-igw.id ...
source = "hashicorp/aws" version = "~> 4.0" } } } provider "aws" { region = "cn-northwest-1" } #terraform init 4.2创建vpc # vi vpc.tf resource "aws_vpc" "tf_vpc" { cidr_block = "10.200.0.0/16" enable_dns_hostnames = "true" ...
Public subnet 访问 Internet. # Internet GWresource"aws_internet_gateway""main-gw"{ vpc_id=aws_vpc.main.id# 这里需要关联到一个 VPCtags={ Name="main"} } [路由表] 跟公网网关相关的“路由表”设置。 # route tablesresource"aws_route_table""main-public"{ ...
resource "aws_route_table" "public" { vpc_id = "${aws_vpc.default.id}" route { cidr_block = "0.0.0.0/0" gateway_id = "${aws_internet_gateway.default.id}" } tags { Name = "publicrt-${var.vpc_name}" } } # PUBLIC SUBNETS - Route associations ...
To create an internet gateway in Terraform, you can use the aws_internet_gateway resource. In this example, we create an internet gateway associated with the aws_vpc.example_vpc VPC. resource "aws_internet_gateway" "example_igw" { vpc_id = "${aws_vpc.example_vpc.id}" tags = { Name ...