-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.tf
72 lines (60 loc) · 1.93 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
provider "aws" {
region = var.aws_region
}
data "aws_caller_identity" "current" {}
data "aws_eks_cluster" "cluster" {
name = module.eks.cluster_id
}
data "aws_eks_cluster_auth" "cluster" {
name = module.eks.cluster_id
}
provider "kubernetes" {
host = data.aws_eks_cluster.cluster.endpoint
cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority[0].data)
token = data.aws_eks_cluster_auth.cluster.token
}
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "~> 2.47"
name = var.aws_vpc_name
cidr = "172.17.0.0/16"
azs = var.aws_availability_zones
private_subnets = ["172.17.0.0/20", "172.17.16.0/20"]
public_subnets = ["172.17.32.0/20", "172.17.48.0/20"]
enable_nat_gateway = true
single_nat_gateway = true
enable_dns_hostnames = true
tags = var.aws_tags
public_subnet_tags = {
"kubernetes.io/cluster/${var.eks_cluster_name}" = "shared"
"kubernetes.io/role/elb" = "1"
}
private_subnet_tags = {
"kubernetes.io/cluster/${var.eks_cluster_name}" = "shared"
"kubernetes.io/role/internal-elb" = "1"
}
}
module "eks" {
source = "terraform-aws-modules/eks/aws"
cluster_name = var.eks_cluster_name
cluster_version = "1.20"
vpc_id = module.vpc.vpc_id
subnets = module.vpc.private_subnets
cluster_service_ipv4_cidr = "172.18.0.0/16"
enable_irsa = true
tags = var.aws_tags
manage_aws_auth = false
node_groups_defaults = {
ami_type = "AL2_x86_64"
disk_size = 64
}
node_groups = {
core = {
desired_capacity = 1
max_capacity = 2
min_capacity = 0
instance_types = ["t3.2xlarge"]
capacity_type = "ON_DEMAND"
}
}
}