forked from harvestdp/rancher-on-eks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
01_eks.tf
71 lines (59 loc) · 1.76 KB
/
01_eks.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
data "aws_vpc" "vpc" {
id = var.vpc_id
}
data "aws_availability_zones" "available" {
}
data "aws_subnet_ids" "cluster_subnet_set" {
count = length(var.subnet_name_filters_for_cluster)
vpc_id = data.aws_vpc.vpc.id
filter {
name = "tag:Name"
values = [var.subnet_name_filters_for_cluster[count.index]]
}
}
data "aws_subnet_ids" "node_subnet_set" {
count = length(var.subnet_name_filters_for_nodes)
vpc_id = data.aws_vpc.vpc.id
filter {
name = "tag:Name"
values = [var.subnet_name_filters_for_nodes[count.index]]
}
}
data "aws_eks_cluster" "cluster" {
name = module.eks.cluster_id
}
data "aws_eks_cluster_auth" "cluster" {
name = module.eks.cluster_id
}
resource "aws_kms_key" "eks" {
description = "${local.cluster_name}-eks-secrets-key"
}
module "eks" {
source = "github.com/terraform-aws-modules/terraform-aws-eks"
cluster_name = local.cluster_name
cluster_version = var.kubernetes_version
vpc_id = data.aws_vpc.vpc.id
wait_for_cluster_interpreter = var.shell_interpreter
subnets = flatten([for subnets in data.aws_subnet_ids.cluster_subnet_set : tolist(subnets.ids)])
cluster_encryption_config = [
{
provider_key_arn = aws_kms_key.eks.arn
resources = ["secrets"]
}
]
workers_group_defaults = {
subnets = flatten([for subnets in data.aws_subnet_ids.node_subnet_set : tolist(subnets.ids)])
asg_max_size = var.node_group_max_size
asg_min_size = var.node_group_min_size
asg_desired_capacity = var.node_group_desired_capacity
instance_type = var.node_group_instance_type
}
node_groups = {
main = {
key_name = ""
}
}
tags = {
Environment = "prod"
}
}