-
Notifications
You must be signed in to change notification settings - Fork 4
/
vpc_and_subnet.tf
53 lines (43 loc) · 1.18 KB
/
vpc_and_subnet.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Creating new VPC with enabled hostname
resource "aws_vpc" "my_vpc" {
cidr_block = "192.168.0.0/16"
enable_dns_hostnames = true
tags = {
Name = "my_vpc"
}
}
# Creating Public Subnet for WordPress
resource "aws_subnet" "public_subnet" {
vpc_id = aws_vpc.my_vpc.id
cidr_block = "192.168.5.0/24"
map_public_ip_on_launch = true
availability_zone = "ap-south-1a"
tags = {
Name = "public_subnet"
}
}
# Creating two private subnets because RDS requires minimum 2 availability zones
resource "aws_subnet" "private_subnet_1" {
vpc_id = aws_vpc.my_vpc.id
cidr_block = "192.168.6.0/24"
availability_zone = "ap-south-1b"
tags = {
Name = "private_subnet_1"
}
}
resource "aws_subnet" "private_subnet_2" {
vpc_id = aws_vpc.my_vpc.id
cidr_block = "192.168.7.0/24"
availability_zone = "ap-south-1c"
tags = {
Name = "private_subnet_2"
}
}
# Creating Database Subnet group under our VPC
resource "aws_db_subnet_group" "db_subnet" {
name = "rds_db"
subnet_ids = [aws_subnet.private_subnet_1.id, aws_subnet.private_subnet_2.id ]
tags = {
Name = "My DB subnet group"
}
}