| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- // Recurso principal para redes
- resource "aws_vpc" "tut-vpc" {
- assign_generated_ipv6_cidr_block = true
- cidr_block = "10.0.0.0/16"
- enable_dns_hostnames = true
- enable_dns_support = true
- tags = {
- Name = "Tutorial"
- }
- }
- // Puerta de enlace para salida a Internet
- // Se adjunta a la VPC
- resource "aws_internet_gateway" "tut-gateway" {
- vpc_id = aws_vpc.tut-vpc.id
- tags = {
- Name = "Tutorial"
- }
- }
- // Sub-red para instancias
- // Se adjunta a la VPC
- // Se definen sus direcciones
- resource "aws_subnet" "tut-subnet-1" {
- assign_ipv6_address_on_creation = true
- availability_zone = "us-west-2a"
- cidr_block = cidrsubnet(aws_vpc.tut-vpc.cidr_block, 8, 1)
- ipv6_cidr_block = cidrsubnet(aws_vpc.tut-vpc.ipv6_cidr_block, 8, 1)
- map_public_ip_on_launch = true
- vpc_id = aws_vpc.tut-vpc.id
- tags = {
- Name = "Tutorial"
- }
- }
- // Rutas para salida a Internet
- // Toma por defecto la tabla predefinida en la VPC
- resource "aws_default_route_table" "tut-routes" {
- default_route_table_id = aws_vpc.tut-vpc.default_route_table_id
- route {
- cidr_block = "0.0.0.0/0"
- gateway_id = aws_internet_gateway.tut-gateway.id
- }
- route {
- ipv6_cidr_block = "::/0"
- gateway_id = aws_internet_gateway.tut-gateway.id
- }
- tags = {
- Name = "Tutorial"
- }
- }
- // Adjunta las rutas par salida a Internet en la sub-red
- resource "aws_route_table_association" "tut-route-1" {
- subnet_id = aws_subnet.tut-subnet-1.id
- route_table_id = aws_default_route_table.tut-routes.id
- }
|