-
Notifications
You must be signed in to change notification settings - Fork 12
/
vpc.tf
49 lines (42 loc) · 1.19 KB
/
vpc.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
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones
# Filter out opt-in availability zones (local zones, as an example)
data "aws_availability_zones" "available" {
filter {
name = "opt-in-status"
values = ["opt-in-not-required"]
}
}
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "3.14.2"
name = var.project_name
cidr = var.cidr
azs = slice(data.aws_availability_zones.available.names, 0, 3)
private_subnets = local.private_subnets
public_subnets = local.public_subnets
enable_nat_gateway = true
enable_dns_hostnames = true
public_subnet_tags = {
"kubernetes.io/role/elb" = 1
"kubernetes.io/cluster/${var.project_name}" = "shared"
}
private_subnet_tags = {
"kubernetes.io/role/internal-elb" = 1
"kubernetes.io/cluster/${var.project_name}" = "shared"
}
tags = {
Operator = "Terraform"
}
}
locals {
private_subnets = [
cidrsubnet(var.cidr, 8, 1),
cidrsubnet(var.cidr, 8, 2),
cidrsubnet(var.cidr, 8, 3)
]
public_subnets = [
cidrsubnet(var.cidr, 8, 4),
cidrsubnet(var.cidr, 8, 5),
cidrsubnet(var.cidr, 8, 6)
]
}