-
Notifications
You must be signed in to change notification settings - Fork 1
/
vpc.tf
82 lines (71 loc) · 1.84 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
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
/*
* Copyright (C) 2019 Risk Focus, Inc. - All Rights Reserved
* You may use, distribute and modify this code under the
* terms of the Apache License Version 2.0.
* http://www.apache.org/licenses
*/
locals {
type_public = {
"type" = "public"
}
type_private = {
"type" = "private"
}
}
//noinspection MissingModule
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = ">=2.15.0"
cidr = var.vpc_cidr
name = local.vpc_name
tags = merge(
local.vpc_tags,
{
"kubernetes.io/cluster/${local.cluster_name}" = "shared"
},
)
public_subnet_tags = local.type_public
private_subnet_tags = local.type_private
public_route_table_tags = local.type_public
private_route_table_tags = local.type_private
public_subnets = [
cidrsubnet(cidrsubnet(var.vpc_cidr, 2, 2), 4, 0),
cidrsubnet(cidrsubnet(var.vpc_cidr, 2, 2), 4, 1),
]
# TODO: use data to get AZS
azs = [
"${local.aws_region}a",
"${local.aws_region}b",
]
private_subnets = [
cidrsubnet(var.vpc_cidr, 2, 0),
cidrsubnet(var.vpc_cidr, 2, 1),
]
enable_dns_hostnames = true
enable_dns_support = true
enable_nat_gateway = true
single_nat_gateway = true
}
resource "aws_security_group" "whitelist" {
name = "${var.project_prefix}-eks-whilelist"
description = "Set of whitelisted IPs for ${var.project_prefix} + GitHub hooks"
vpc_id = module.vpc.vpc_id
ingress {
from_port = 0
to_port = 0
protocol = -1
cidr_blocks = var.ip_whitelist
}
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = concat(local.github_meta_hooks, local.atlassian_inbound)
}
ingress {
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = concat(local.github_meta_hooks, local.atlassian_inbound)
}
}