Skip to content

Instantly share code, notes, and snippets.

@SharmilaS22
Created July 3, 2023 13:35
Show Gist options
  • Save SharmilaS22/1bc9bbee06d1216f854228e41d967286 to your computer and use it in GitHub Desktop.
Save SharmilaS22/1bc9bbee06d1216f854228e41d967286 to your computer and use it in GitHub Desktop.
VPC and subnets
# VPC
resource "aws_vpc" "sh_main" {
cidr_block = "10.0.0.0/23" # 512 IPs
tags = {
Name = "sharmi-vpc"
}
}
# Creating public subnet
resource "aws_subnet" "sh_subnet_1" {
vpc_id = aws_vpc.sh_main.id
cidr_block = "10.0.0.0/27" #32 IPs
map_public_ip_on_launch = true # public subnet
availability_zone = "us-east-1a"
}
# Creating 1st private subnet
resource "aws_subnet" "sh_subnet_1a" {
vpc_id = aws_vpc.sh_main.id
cidr_block = "10.0.0.32/27" #32 IPs
map_public_ip_on_launch = false # private subnet
availability_zone = "us-east-1a"
}
# Creating 2nd private subnet
resource "aws_subnet" "sh_subnet_2" {
vpc_id = aws_vpc.sh_main.id
cidr_block = "10.0.1.0/27" #32 IPs
map_public_ip_on_launch = false # private subnet
availability_zone = "us-east-1b"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment