-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
74 lines (61 loc) · 1.72 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
resource "aws_security_group" "worker_security_group" {
name_prefix = "worker_security_group"
vpc_id = module.vpc.vpc_id
ingress {
from_port = 0
to_port = 0
protocol = "tcp"
cidr_blocks = [
"10.0.0.0/16",
]
}
}
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "2.25.0"
name = "this"
cidr = var.network_address
azs = data.aws_availability_zones.available.names
private_subnets = var.private_subnets
public_subnets = var.public_subnets
enable_nat_gateway = true
single_nat_gateway = true
enable_dns_hostnames = true
tags = {
Name = format("%s-vpc", var.stage)
}
public_subnet_tags = {
Name = format("%s-public-subnet", var.stage)
"kubernetes.io/cluster/${local.cluster_name}" = "shared"
}
private_subnet_tags = {
Name = format("%s-private-subnet", var.stage)
"kubernetes.io/cluster/${local.cluster_name}" = "shared"
}
}
module "eks" {
source = "terraform-aws-modules/eks/aws"
cluster_name = local.cluster_name
subnets = module.vpc.private_subnets
tags = {
Name = format("%s-eks", var.stage)
Environment = var.stage
}
vpc_id = module.vpc.vpc_id
node_groups = {
default = {
desired_capacity = var.desired_nodes
max_capacity = var.max_nodes
min_capacity = var.min_nodes
instance_type = var.instance_type
subnets = module.vpc.private_subnets
role_arn = aws_iam_role.this.arn
additional_tags = {
Name = format("%s-eks-node", "${var.stage}")
}
k8s_labels = {
Name = format("%s-eks-node", "${var.stage}")
}
}
}
}