Skip to content

Commit 89f0231

Browse files
author
Max Glotov
committed
add generation of version.tf; add descriptions for variables
1 parent 46d14ad commit 89f0231

File tree

36 files changed

+417
-601
lines changed

36 files changed

+417
-601
lines changed

terraform/.terraform-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.4
1+
1.7.3

terraform/modules/aws-acm/versions.tf

-10
This file was deleted.

terraform/modules/aws-cis-benchmark-alerts/versions.tf

-10
This file was deleted.

terraform/modules/aws-cost-allocation-tags/versions.tf

-10
This file was deleted.

terraform/modules/aws-ebs-encryption-default/versions.tf

-10
This file was deleted.

terraform/modules/aws-eks/main.tf

+12-23
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
locals {
2-
3-
eks_map_roles = [
4-
{
5-
rolearn = "arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/administrator"
6-
username = "administrator"
7-
groups = ["system:masters"]
8-
}
9-
]
10-
}
11-
121
data "aws_ami" "eks_default_arm64" {
132
most_recent = true
143
owners = ["amazon"]
@@ -23,16 +12,18 @@ data "aws_ami" "eks_default_arm64" {
2312
#tfsec:ignore:aws-vpc-no-public-egress-sgr tfsec:ignore:aws-eks-enable-control-plane-logging tfsec:ignore:aws-eks-encrypt-secrets tfsec:ignore:aws-eks-no-public-cluster-access tfsec:ignore:aws-eks-no-public-cluster-access-to-cidr
2413
module "eks" {
2514
source = "terraform-aws-modules/eks/aws"
26-
version = "19.12.0"
27-
28-
cluster_name = var.name
29-
cluster_version = var.eks_cluster_version
30-
subnet_ids = var.private_subnets
31-
control_plane_subnet_ids = var.intra_subnets
32-
enable_irsa = true
33-
manage_aws_auth_configmap = true
34-
create_aws_auth_configmap = false
35-
aws_auth_roles = local.eks_map_roles
15+
version = "20.8.4"
16+
17+
cluster_name = var.name
18+
cluster_version = var.eks_cluster_version
19+
vpc_id = var.vpc_id
20+
subnet_ids = var.private_subnets
21+
control_plane_subnet_ids = var.intra_subnets
22+
23+
authentication_mode = "API"
24+
enable_cluster_creator_admin_permissions = true
25+
access_entries = var.access_entries
26+
3627
cluster_addons = {
3728
coredns = {
3829
most_recent = true
@@ -56,8 +47,6 @@ module "eks" {
5647
cluster_enabled_log_types = var.eks_cluster_enabled_log_types
5748
cloudwatch_log_group_retention_in_days = var.eks_cloudwatch_log_group_retention_in_days
5849

59-
vpc_id = var.vpc_id
60-
6150
cluster_endpoint_public_access = var.eks_cluster_endpoint_public_access
6251
cluster_endpoint_private_access = var.eks_cluster_endpoint_private_access
6352
cluster_endpoint_public_access_cidrs = var.eks_cluster_endpoint_only_pritunl ? ["0.0.0.0/0"] : ["0.0.0.0/0"]
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
provider "kubernetes" {
2+
host = module.eks.cluster_endpoint
3+
cluster_ca_certificate = base64decode(module.eks.cluster_certificate_authority_data)
4+
token = data.aws_eks_cluster_auth.main.token
5+
}
6+
7+
data "aws_eks_cluster_auth" "main" {
8+
name = module.eks.cluster_name
9+
}
10+
11+
data "aws_caller_identity" "current" {}

terraform/modules/aws-eks/variables.tf

+23-20
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,40 @@
11
variable "name" {
2-
type = string
2+
type = string
3+
description = "Name, required to create unique resource names"
34
}
45

56
variable "env" {
6-
type = string
7+
type = string
8+
description = "Environment name"
79
}
810

911
variable "region" {
10-
type = string
12+
type = string
13+
description = "Infrastructure region"
1114
}
1215

1316
variable "vpc_id" {
14-
type = string
17+
type = string
18+
description = "The ID of the VPC where cluster will created"
1519
}
1620

1721
variable "intra_subnets" {
18-
type = list(any)
22+
type = list(any)
23+
description = "A list of intra subnets inside the VPC"
1924
}
2025

2126
variable "private_subnets" {
22-
type = list(any)
27+
type = list(any)
28+
description = "A list of private subnets inside the VPC"
2329
}
2430

2531
variable "public_subnets" {
26-
type = list(any)
32+
type = list(any)
33+
description = "A list of public subnets inside the VPC"
2734
}
2835

2936
variable "eks_cluster_version" {
30-
default = "1.25"
37+
default = "1.29"
3138
description = "Version of the EKS K8S cluster"
3239
}
3340

@@ -64,15 +71,10 @@ variable "node_group_default" {
6471
description = "Default node group configuration"
6572
}
6673

67-
variable "eks_map_roles" {
68-
description = "Additional IAM roles to add to the aws-auth configmap."
69-
type = list(object({
70-
rolearn = string
71-
username = string
72-
groups = list(string)
73-
}))
74-
75-
default = []
74+
variable "access_entries" {
75+
type = any
76+
default = {}
77+
description = "Map of access entries to add to the cluster"
7678
}
7779

7880
variable "eks_cluster_enabled_log_types" {
@@ -101,7 +103,7 @@ variable "eks_cluster_endpoint_public_access" {
101103

102104
variable "eks_cluster_endpoint_private_access" {
103105
type = bool
104-
default = false
106+
default = true
105107
description = "Enable or not private access to cluster endpoint"
106108
}
107109

@@ -112,6 +114,7 @@ variable "eks_cluster_endpoint_only_pritunl" {
112114
}
113115

114116
variable "tags" {
115-
type = any
116-
default = {}
117+
type = any
118+
default = {}
119+
description = "A map of additional tags to add to resources"
117120
}

terraform/modules/aws-eks/versions.tf

-14
This file was deleted.

terraform/modules/aws-password-policy/versions.tf

-10
This file was deleted.

terraform/modules/aws-pritunl/versions.tf

-10
This file was deleted.

terraform/modules/aws-r53/versions.tf

-10
This file was deleted.

terraform/modules/aws-vpc/main.tf

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
locals {
2-
az_count = length(var.azs) - 1
2+
az_count = length(var.azs)
33
cidr_subnets = [for cidr_block in cidrsubnets(var.cidr, 2, 2, 2, 2) : cidrsubnets(cidr_block, 4, 4, 4, 4)]
44
private_subnets = chunklist(local.cidr_subnets[0], local.az_count)[0]
55
public_subnets = chunklist(local.cidr_subnets[1], local.az_count)[0]
@@ -9,7 +9,7 @@ locals {
99

1010
module "vpc" {
1111
source = "terraform-aws-modules/vpc/aws"
12-
version = "4.0.1"
12+
version = "5.7.1"
1313

1414
name = var.name
1515
cidr = var.cidr
@@ -84,7 +84,7 @@ module "vpc" {
8484

8585
module "vpc_gateway_endpoints" {
8686
source = "terraform-aws-modules/vpc/aws//modules/vpc-endpoints"
87-
version = "4.0.1"
87+
version = "5.7.1"
8888

8989
vpc_id = module.vpc.vpc_id
9090

+18-9
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
variable "name" {
2-
type = string
3-
}
4-
variable "single_nat_gateway" {
5-
type = bool
6-
default = false
2+
type = string
3+
description = "Name, required to create unique resource names"
74
}
5+
86
variable "cidr" {
9-
type = string
7+
type = string
8+
description = "The IPv4 CIDR block for the VPC"
109
}
10+
1111
variable "azs" {
12-
type = list(any)
12+
type = list(any)
13+
description = "A list of availability zones names or ids in the region"
14+
}
15+
16+
variable "single_nat_gateway" {
17+
type = bool
18+
default = false
19+
description = "Should be true if you want to provision a single shared NAT Gateway across all of your private networks"
1320
}
21+
1422
variable "tags" {
15-
type = any
16-
default = {}
23+
type = any
24+
default = {}
25+
description = "A map of additional tags to add to resources"
1726
}

terraform/modules/aws-vpc/versions.tf

-10
This file was deleted.

terraform/modules/k8s-addons/main.tf

+32
Original file line numberDiff line numberDiff line change
@@ -1 +1,33 @@
1+
provider "kubernetes" {
2+
host = data.aws_eks_cluster.main.endpoint
3+
cluster_ca_certificate = base64decode(data.aws_eks_cluster.main.certificate_authority.0.data)
4+
token = data.aws_eks_cluster_auth.main.token
5+
}
6+
7+
provider "kubectl" {
8+
host = data.aws_eks_cluster.main.endpoint
9+
cluster_ca_certificate = base64decode(data.aws_eks_cluster.main.certificate_authority.0.data)
10+
token = data.aws_eks_cluster_auth.main.token
11+
}
12+
13+
provider "helm" {
14+
kubernetes {
15+
host = data.aws_eks_cluster.main.endpoint
16+
cluster_ca_certificate = base64decode(data.aws_eks_cluster.main.certificate_authority.0.data)
17+
token = data.aws_eks_cluster_auth.main.token
18+
}
19+
20+
experiments {
21+
manifest = true
22+
}
23+
}
24+
25+
data "aws_eks_cluster" "main" {
26+
name = var.eks_cluster_id
27+
}
28+
29+
data "aws_eks_cluster_auth" "main" {
30+
name = var.eks_cluster_id
31+
}
32+
133
data "aws_caller_identity" "current" {}

0 commit comments

Comments
 (0)