-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.tf
90 lines (62 loc) · 2.5 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
module "aws_vpc_module" {
source = "./modules/aws_vpc"
for_each = var.vpc_config
vpc_cidr_block = each.value.vpc_cidr_block
instance_tenancy = each.value.instance_tenancy
tags = each.value.tags
}
module "aws_subnet_module" {
source = "./modules/aws_subnets"
for_each = var.subnet_config
subnet_cidr_block = each.value.subnet_cidr_block
availability_zone = each.value.availability_zone
vpc_id = module.aws_vpc_module[each.value.vpc_name].vpc_id
tags = each.value.tags
}
module "IGW_module" {
source = "./modules/aws_IGW"
for_each = var.IGW_config
vpc_id = module.aws_vpc_module[each.value.vpc_name].vpc_id
tags = each.value.tags
}
module "rtb_module" {
source = "./modules/aws_route_table"
for_each = var.rtb_config
vpc_id = module.aws_vpc_module[each.value.vpc_name].vpc_id
gateway_id = each.value.private == 0 ? module.IGW_module[each.value.gateway_name].IGW_id : module.nat_gateway_module[each.value.gateway_name].nat_gateway_id
tags = each.value.tags
}
module "rtb_assoc_module" {
source = "./modules/aws_route_table_association"
for_each = var.rtb_assoc_config
subnet_id = module.aws_subnet_module[each.value.subnet_name].subnet_id
route_table_id = module.rtb_module[each.value.route_table_name].rtb_id
}
module "nat_gateway_module" {
source = "./modules/aws_nat_gateway"
for_each = var.natgw_config
subnet_id = module.aws_subnet_module[each.value.subnet_name].subnet_id
allocation_id = module.eip_module[each.value.eip_name].eip_id
tags = each.value.tags
}
module "eip_module" {
source = "./modules/aws_eip"
for_each = var.eip_config
tags = each.value.tags
}
module "eks_module" {
source = "./modules/aws_eks"
for_each = var.eks_cluster_config
cluster_name = each.value.cluster_name
subnet_ids = [module.aws_subnet_module[each.value.subnet1].subnet_id, module.aws_subnet_module[each.value.subnet2].subnet_id, module.aws_subnet_module[each.value.subnet3].subnet_id , module.aws_subnet_module[each.value.subnet4].subnet_id]
tags= each.value.tags
}
module "nodegroups_module" {
source = "./modules/aws_eks_nodegroups"
for_each = var.nodegroup_config
node_group_name = each.value.node_group_name
cluster_name = module.eks_module[each.value.cluster_name].eks_cluster_output_name
node_i_am_role = each.value.node_i_am_role
subnet_ids = [module.aws_subnet_module[each.value.subnet1].subnet_id, module.aws_subnet_module[each.value.subnet2].subnet_id]
tags = each.value.tags
}