-
Notifications
You must be signed in to change notification settings - Fork 1
/
subnets.tf
30 lines (26 loc) · 901 Bytes
/
subnets.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
####################################
#### PUBLIC AND PRIVATE SUBNETS ####
####################################
resource "aws_subnet" "public" {
count = length(var.subnet_cidr_public)
vpc_id = aws_vpc.tf_vpc.id
cidr_block = var.subnet_cidr_public[count.index]
availability_zone = var.AZ[count.index]
map_public_ip_on_launch = true
}
resource "aws_subnet" "private" {
count = length(var.subnet_cidr_private)
vpc_id = aws_vpc.tf_vpc.id
cidr_block = var.subnet_cidr_private[count.index]
availability_zone = var.AZ[count.index]
}
############################
##### RDS SUBNET GROUP #####
############################
resource "aws_db_subnet_group" "rd-subnet" {
name = "db-subnet-tf"
subnet_ids = [aws_subnet.private[0].id, aws_subnet.private[1].id]
tags = {
Name = "rd-subnet"
}
}