aboutsummaryrefslogtreecommitdiffstats
path: root/fdio.infra.terraform/terraform-aws-subnet/main.tf
blob: d14aa5f82793c52c95bad0264f64d05527bb5adb (plain)
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
locals {
  tags = {
    "Name"        = "${var.tags_name}"
    "Environment" = "${var.tags_environment}"
  }
}

# Create VPC IPv4 CIDR Block Association
resource "aws_vpc_ipv4_cidr_block_association" "ipv4_cidr_block_association" {
  cidr_block = var.subnet_cidr_block
  vpc_id     = var.subnet_vpc_id
}

# Create Subnet
resource "aws_subnet" "subnet" {
  depends_on = [
    aws_vpc_ipv4_cidr_block_association.ipv4_cidr_block_association
  ]
  assign_ipv6_address_on_creation = var.subnet_assign_ipv6_address_on_creation
  availability_zone               = var.subnet_availability_zone
  cidr_block                      = var.subnet_cidr_block
  ipv6_cidr_block                 = var.subnet_ipv6_cidr_block
  map_public_ip_on_launch         = var.subnet_map_public_ip_on_launch
  tags                            = local.tags
  vpc_id                          = var.subnet_vpc_id
}