-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvpc.tf
More file actions
95 lines (81 loc) · 2.12 KB
/
vpc.tf
File metadata and controls
95 lines (81 loc) · 2.12 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
data "aws_vpc" "vpc" {
tags = {
Name = coalesce(var.vpc_lookup_override, "${var.ado}-*-${var.env}")
}
}
# all subnets
data "aws_subnets" "all_subnets" {
filter {
name = "vpc-id"
values = [data.aws_vpc.vpc.id]
}
}
# public subnets
data "aws_subnets" "public" {
filter {
name = "tag:Name"
values = [
try(var.subnet_lookup_overrides.public, "${var.ado}-*-${var.env}-public-*")
]
}
}
# private subnets
data "aws_subnets" "private" {
filter {
name = "tag:Name"
values = [
try(var.subnet_lookup_overrides.private, "${var.ado}-*-${var.env}-private-*")
]
}
}
data "aws_subnets" "container" {
filter {
name = "tag:Name"
values = [
try(var.subnet_lookup_overrides.container, "${var.ado}-*-${var.env}-unroutable-*")
]
}
}
data "aws_subnet" "container" {
for_each = toset(local.all_container_subnet_ids)
id = each.key
}
data "aws_ec2_managed_prefix_list" "vpn_prefix_list" {
name = "cmscloud-vpn"
}
data "aws_ec2_managed_prefix_list" "cmscloud_shared_services_pl" {
name = "cmscloud-shared-services"
}
data "aws_ec2_managed_prefix_list" "cmscloud_security_tools" {
name = "cmscloud-security-tools"
}
# data "aws_ec2_managed_prefix_list" "cmscloud_public_pl" {
# name = "cmscloud-public"
# }
data "aws_ec2_managed_prefix_list" "zscaler_pl" {
name = "zscaler"
}
#non-prod route table
data "aws_route_table" "all_private_route_tables" {
for_each = toset(local.all_private_subnet_ids)
subnet_id = each.key
}
# Creating subnet tags for load balancer controller
resource "aws_ec2_tag" "elb_controller" {
for_each = toset(data.aws_subnets.public.ids)
resource_id = each.value
key = "kubernetes.io/role/elb"
value = "1"
}
resource "aws_ec2_tag" "internal_elb_controller" {
for_each = toset(data.aws_subnets.private.ids)
resource_id = each.value
key = "kubernetes.io/role/internal-elb"
value = "1"
}
resource "aws_ec2_tag" "all_subnets" {
for_each = toset(data.aws_subnets.all_subnets.ids)
resource_id = each.value
key = "kubernetes.io/cluster/${module.eks.cluster_name}"
value = "shared"
}