-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.tf
50 lines (40 loc) · 1.83 KB
/
main.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
locals {
zones = coalescelist(var.availability_zones, data.aws_availability_zones.available.names)
cidr = var.cidr != null ? var.cidr : "10.${var.network}.0.0/16"
private = var.cidr != null ? [for i, z in local.zones : cidrsubnet(local.cidr, var.network_delimiter, i)] : [ for i, _ in local.zones : "10.${var.network}.20${i}.0/24" ]
public = var.cidr != null ? [for i, z in local.zones : cidrsubnet(local.cidr, var.network_delimiter, pow(2, var.network_delimiter) - i)] : [ for i, _ in local.zones:"10.${var.network}.${i}.0/24" ]
}
data "aws_availability_zones" "available" {}
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "v2.64.0"
name = "${var.environment}-${var.cluster_name}"
cidr = local.cidr
azs = local.zones
private_subnets = local.private
public_subnets = local.public
enable_nat_gateway = true
single_nat_gateway = var.single_nat
enable_dns_hostnames = true
enable_dns_support = true
public_subnet_tags = {
Name = "${var.environment}-${var.cluster_name}-public"
KubernetesCluster = var.cluster_name
Environment = var.environment
Project = var.project
"kubernetes.io/role/elb" = "1"
"kubernetes.io/cluster/${var.cluster_name}" = "owned"
"kubernetes.io/cluster/${var.cluster_name}" = "shared"
}
private_subnet_tags = {
Name = "${var.environment}-${var.cluster_name}-private"
"kubernetes.io/role/elb-internal" = "1"
"kubernetes.io/cluster/${var.cluster_name}" = "owned"
}
tags = {
Name = "${var.environment}-${var.cluster_name}"
Environment = var.environment
Project = var.project
Terraform = "true"
}
}