From dd34c199b3f4ab7412c14338f075b02235ad2b00 Mon Sep 17 00:00:00 2001 From: Aman Verma <141578852+amanverma678@users.noreply.github.com> Date: Fri, 25 Oct 2024 11:53:17 +0000 Subject: [PATCH 01/48] bug: aws-auth-config-fixed --- aws_auth.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aws_auth.tf b/aws_auth.tf index 8dba871..da4e138 100644 --- a/aws_auth.tf +++ b/aws_auth.tf @@ -88,9 +88,9 @@ data "aws_eks_cluster_auth" "eks" { } provider "kubernetes" { - token = data.aws_eks_cluster_auth.eks[0].token - host = data.aws_eks_cluster.eks[0].endpoint - cluster_ca_certificate = base64decode(data.aws_eks_cluster.eks[0].certificate_authority.0.data) + token = var.apply_config_map_aws_auth ? data.aws_eks_cluster_auth.eks[0].token : "" + host = var.apply_config_map_aws_auth ? data.aws_eks_cluster.eks[0].endpoint : "" + cluster_ca_certificate = var.apply_config_map_aws_auth ? base64decode(data.aws_eks_cluster.eks[0].certificate_authority[0].data) : "" } resource "kubernetes_config_map" "aws_auth_ignore_changes" { From 2518b45e63120072cd0426e6dad3051a8b50f419 Mon Sep 17 00:00:00 2001 From: Aman Verma <141578852+amanverma678@users.noreply.github.com> Date: Fri, 15 Nov 2024 00:47:48 +0530 Subject: [PATCH 02/48] fix: warning --- aws_auth.tf | 5 ++--- aws_node_groups.tf | 4 ++-- self_node_groups.tf | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/aws_auth.tf b/aws_auth.tf index da4e138..a80d08d 100644 --- a/aws_auth.tf +++ b/aws_auth.tf @@ -29,8 +29,7 @@ locals { - certificate_authority_data_list = coalescelist(aws_eks_cluster.default.*.certificate_authority, [[{ data : "" }]]) - certificate_authority_data_list_internal = local.certificate_authority_data_list[0] + certificate_authority_data_list = coalescelist([for cert in aws_eks_cluster.default : cert.certificate_authority], [{ data : "" }])` certificate_authority_data_list_internal = local.certificate_authority_data_list[0] certificate_authority_data_map = local.certificate_authority_data_list_internal[0] certificate_authority_data = local.certificate_authority_data_map["data"] @@ -38,7 +37,7 @@ locals { # Note that we don't need to do this for managed Node Groups since EKS adds their roles to the ConfigMap automatically map_worker_roles = [ { - rolearn : aws_iam_role.node_groups.0.arn + rolearn : aws_iam_role.node_groups.[0].arn username : "system:node:{{EC2PrivateDNSName}}" groups : [ "system:bootstrappers", diff --git a/aws_node_groups.tf b/aws_node_groups.tf index d80b932..3826b97 100644 --- a/aws_node_groups.tf +++ b/aws_node_groups.tf @@ -9,8 +9,8 @@ module "eks_managed_node_group" { cluster_version = var.kubernetes_version vpc_security_group_ids = compact( concat( - aws_security_group.node_group.*.id, - aws_eks_cluster.default.*.vpc_config.0.cluster_security_group_id, + aws_security_group.node_group.[*].id, + aws_eks_cluster.default.[*].vpc_config.0.cluster_security_group_id, var.nodes_additional_security_group_ids ) diff --git a/self_node_groups.tf b/self_node_groups.tf index 85d414c..1a94df9 100644 --- a/self_node_groups.tf +++ b/self_node_groups.tf @@ -20,8 +20,8 @@ module "self_managed_node_group" { cluster_name = aws_eks_cluster.default[0].name security_group_ids = compact( concat( - aws_security_group.node_group.*.id, - aws_eks_cluster.default.*.vpc_config.0.cluster_security_group_id + aws_security_group.node_group.[*].id, + aws_eks_cluster.default.[*].vpc_config.0.cluster_security_group_id ) ) From bd5c55faf9f05c7c60cd41895b0287233c27f9b5 Mon Sep 17 00:00:00 2001 From: Aman Verma <141578852+amanverma678@users.noreply.github.com> Date: Fri, 15 Nov 2024 01:17:22 +0530 Subject: [PATCH 03/48] fix: warnings --- aws_auth.tf | 4 ++-- aws_node_groups.tf | 4 ++-- self_node_groups.tf | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/aws_auth.tf b/aws_auth.tf index a80d08d..fe1c28b 100644 --- a/aws_auth.tf +++ b/aws_auth.tf @@ -29,7 +29,7 @@ locals { - certificate_authority_data_list = coalescelist([for cert in aws_eks_cluster.default : cert.certificate_authority], [{ data : "" }])` certificate_authority_data_list_internal = local.certificate_authority_data_list[0] + certificate_authority_data_list = coalescelist(aws_eks_cluster.default.[*].certificate_authority, [[{ data : "" }]]) certificate_authority_data_map = local.certificate_authority_data_list_internal[0] certificate_authority_data = local.certificate_authority_data_map["data"] @@ -37,7 +37,7 @@ locals { # Note that we don't need to do this for managed Node Groups since EKS adds their roles to the ConfigMap automatically map_worker_roles = [ { - rolearn : aws_iam_role.node_groups.[0].arn + rolearn : aws_iam_role.node_groups[0].arn username : "system:node:{{EC2PrivateDNSName}}" groups : [ "system:bootstrappers", diff --git a/aws_node_groups.tf b/aws_node_groups.tf index 3826b97..a27994f 100644 --- a/aws_node_groups.tf +++ b/aws_node_groups.tf @@ -9,8 +9,8 @@ module "eks_managed_node_group" { cluster_version = var.kubernetes_version vpc_security_group_ids = compact( concat( - aws_security_group.node_group.[*].id, - aws_eks_cluster.default.[*].vpc_config.0.cluster_security_group_id, + aws_security_group.node_group[*].id, + aws_eks_cluster.default[*].vpc_config.0.cluster_security_group_id, var.nodes_additional_security_group_ids ) diff --git a/self_node_groups.tf b/self_node_groups.tf index 1a94df9..83f3807 100644 --- a/self_node_groups.tf +++ b/self_node_groups.tf @@ -20,8 +20,8 @@ module "self_managed_node_group" { cluster_name = aws_eks_cluster.default[0].name security_group_ids = compact( concat( - aws_security_group.node_group.[*].id, - aws_eks_cluster.default.[*].vpc_config.0.cluster_security_group_id + aws_security_group.node_group[*].id, + aws_eks_cluster.default[*].vpc_config.0.cluster_security_group_id ) ) From c130ab227308ae1cdc74485012c21b765e89ec0a Mon Sep 17 00:00:00 2001 From: Aman Verma <141578852+amanverma678@users.noreply.github.com> Date: Fri, 15 Nov 2024 01:19:12 +0530 Subject: [PATCH 04/48] fix: warnings --- aws_auth.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws_auth.tf b/aws_auth.tf index fe1c28b..d30e350 100644 --- a/aws_auth.tf +++ b/aws_auth.tf @@ -29,7 +29,7 @@ locals { - certificate_authority_data_list = coalescelist(aws_eks_cluster.default.[*].certificate_authority, [[{ data : "" }]]) + certificate_authority_data_list = coalescelist(aws_eks_cluster.default[*].certificate_authority, [[{ data : "" }]]) certificate_authority_data_map = local.certificate_authority_data_list_internal[0] certificate_authority_data = local.certificate_authority_data_map["data"] From 803e871176010d9be21c9335445c6ff9a51b078d Mon Sep 17 00:00:00 2001 From: Aman Verma <141578852+amanverma678@users.noreply.github.com> Date: Fri, 15 Nov 2024 01:57:22 +0530 Subject: [PATCH 05/48] fix: warnings --- aws_auth.tf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aws_auth.tf b/aws_auth.tf index d30e350..47d5bc3 100644 --- a/aws_auth.tf +++ b/aws_auth.tf @@ -32,6 +32,8 @@ locals { certificate_authority_data_list = coalescelist(aws_eks_cluster.default[*].certificate_authority, [[{ data : "" }]]) certificate_authority_data_map = local.certificate_authority_data_list_internal[0] certificate_authority_data = local.certificate_authority_data_map["data"] + certificate_authority_data_list_internal = local.certificate_authority_data_list[0] + # Add worker nodes role ARNs (could be from many un-managed worker groups) to the ConfigMap # Note that we don't need to do this for managed Node Groups since EKS adds their roles to the ConfigMap automatically From c7c5dfa73c865d2d4aec22d47ebc14d441bc5594 Mon Sep 17 00:00:00 2001 From: Aman Verma <141578852+amanverma678@users.noreply.github.com> Date: Fri, 15 Nov 2024 02:06:49 +0530 Subject: [PATCH 06/48] fix: warnings --- aws_node_groups.tf | 2 +- main.tf | 6 +++--- self_node_groups.tf | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/aws_node_groups.tf b/aws_node_groups.tf index a27994f..c1db76a 100644 --- a/aws_node_groups.tf +++ b/aws_node_groups.tf @@ -10,7 +10,7 @@ module "eks_managed_node_group" { vpc_security_group_ids = compact( concat( aws_security_group.node_group[*].id, - aws_eks_cluster.default[*].vpc_config.0.cluster_security_group_id, + aws_eks_cluster.default[*].vpc_config[0].cluster_security_group_id, var.nodes_additional_security_group_ids ) diff --git a/main.tf b/main.tf index d685021..547f6ec 100644 --- a/main.tf +++ b/main.tf @@ -91,15 +91,15 @@ resource "aws_eks_cluster" "default" { data "tls_certificate" "cluster" { count = var.enabled && var.oidc_provider_enabled ? 1 : 0 - url = aws_eks_cluster.default[0].identity.0.oidc.0.issuer + url = aws_eks_cluster.default[0].identity[0].oidc[0].issuer } resource "aws_iam_openid_connect_provider" "default" { count = var.enabled && var.oidc_provider_enabled ? 1 : 0 - url = aws_eks_cluster.default[0].identity.0.oidc.0.issuer + url = aws_eks_cluster.default[0].identity[0].oidc[0].issuer client_id_list = distinct(compact(concat(["sts.${data.aws_partition.current.dns_suffix}"], var.openid_connect_audiences))) - thumbprint_list = [data.tls_certificate.cluster[0].certificates.0.sha1_fingerprint] + thumbprint_list = [data.tls_certificate.cluster[0].certificates[0].sha1_fingerprint] tags = module.labels.tags } diff --git a/self_node_groups.tf b/self_node_groups.tf index 83f3807..97b1652 100644 --- a/self_node_groups.tf +++ b/self_node_groups.tf @@ -21,7 +21,7 @@ module "self_managed_node_group" { security_group_ids = compact( concat( aws_security_group.node_group[*].id, - aws_eks_cluster.default[*].vpc_config.0.cluster_security_group_id + aws_eks_cluster.default[*].vpc_config[0].cluster_security_group_id ) ) From 0b0480e28cf065588d292f3f5a7e0902b630e555 Mon Sep 17 00:00:00 2001 From: Aman Verma <141578852+amanverma678@users.noreply.github.com> Date: Tue, 19 Nov 2024 15:00:48 +0530 Subject: [PATCH 07/48] fix: warnings --- versions.tf | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/versions.tf b/versions.tf index 8c08eed..655148b 100644 --- a/versions.tf +++ b/versions.tf @@ -7,5 +7,17 @@ terraform { source = "hashicorp/aws" version = ">= 5.11.0" } + template = { + source = "hashicorp/template" + version = ">= 2.2.0" # Update to the minimum required version + } + null = { + source = "hashicorp/null" + version = ">= 3.2.3" # Update to the minimum required version + } + kubernetes = { + source = "hashicorp/kubernetes" + version = ">= 2.33.0" # Update to the minimum required version + } } } \ No newline at end of file From fe824f0083e3f8121b274e564f61228e1bbf2385 Mon Sep 17 00:00:00 2001 From: Aman Verma <141578852+amanverma678@users.noreply.github.com> Date: Tue, 19 Nov 2024 15:58:25 +0530 Subject: [PATCH 08/48] fix: warnings --- examples/aws_managed/example.tf | 4 +++- locals.tf | 4 ++++ variables.tf | 20 ++++++++++---------- versions.tf | 4 ++++ 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/examples/aws_managed/example.tf b/examples/aws_managed/example.tf index 9303b2e..d06d76c 100644 --- a/examples/aws_managed/example.tf +++ b/examples/aws_managed/example.tf @@ -54,6 +54,8 @@ module "subnets" { extra_private_tags = { "kubernetes.io/cluster/${module.eks.cluster_name}" = "owned" "kubernetes.io/role/internal-elb" = "1" + + tags = locals.tags } public_inbound_acl_rules = [ @@ -279,7 +281,7 @@ module "eks" { vpc_id = module.vpc.vpc_id subnet_ids = module.subnets.private_subnet_id allowed_security_groups = [module.ssh.security_group_id] - eks_additional_security_group_ids = ["${module.ssh.security_group_id}", "${module.http_https.security_group_id}"] + eks_additional_security_group_ids = module.ssh.security_group_id, module.http_https.security_group_id allowed_cidr_blocks = [local.vpc_cidr_block] # AWS Managed Node Group diff --git a/locals.tf b/locals.tf index c22166b..bb22916 100644 --- a/locals.tf +++ b/locals.tf @@ -7,4 +7,8 @@ locals { aws_policy_prefix = format("arn:%s:iam::aws:policy", data.aws_partition.current.partition) create_outposts_local_cluster = length(var.outpost_config) > 0 + resource "local_file" "kubeconfig" { + count = var.enabled ? 1 : 0 + filename = "${path.module}/kubeconfig_generated" + content = data.template_file.kubeconfig[0].rendered } diff --git a/variables.tf b/variables.tf index c9a54b7..ecaadae 100644 --- a/variables.tf +++ b/variables.tf @@ -229,11 +229,11 @@ variable "endpoint_public_access" { description = "Indicates whether or not the Amazon EKS public API server endpoint is enabled. Default to AWS EKS resource and it is true." } -variable "vpc_security_group_ids" { - type = list(string) - default = [] - description = "A list of security group IDs to associate" -} +#variable "vpc_security_group_ids" { +# type = list(string) +# default = [] +# description = "A list of security group IDs to associate" +#} #-----------------------------------------------TimeOuts---------------------------------------------------------------- variable "cluster_timeouts" { @@ -320,11 +320,11 @@ variable "managed_node_group" { #-----------------------------------------------ASG-Schedule---------------------------------------------------------------- -variable "create_schedule" { - description = "Determines whether to create autoscaling group schedule or not" - type = bool - default = true -} +#variable "create_schedule" { +# description = "Determines whether to create autoscaling group schedule or not" +# type = bool +# default = true +#} variable "schedules" { description = "Map of autoscaling group schedule to create" diff --git a/versions.tf b/versions.tf index 655148b..5e4bf85 100644 --- a/versions.tf +++ b/versions.tf @@ -19,5 +19,9 @@ terraform { source = "hashicorp/kubernetes" version = ">= 2.33.0" # Update to the minimum required version } + tls = { + source = "hashicorp/tls" + version = ">= 4.0.6" # Specify the appropriate version + } } } \ No newline at end of file From 4612ee5a7f6160c72bfbb0b1df08fa67cf2921e9 Mon Sep 17 00:00:00 2001 From: Aman Verma <141578852+amanverma678@users.noreply.github.com> Date: Tue, 19 Nov 2024 16:00:16 +0530 Subject: [PATCH 09/48] fix: warnings --- locals.tf | 1 + 1 file changed, 1 insertion(+) diff --git a/locals.tf b/locals.tf index bb22916..64a31be 100644 --- a/locals.tf +++ b/locals.tf @@ -12,3 +12,4 @@ locals { filename = "${path.module}/kubeconfig_generated" content = data.template_file.kubeconfig[0].rendered } +} \ No newline at end of file From 1d162907dabb4ad4de30cc6133d97a05f2c13ed7 Mon Sep 17 00:00:00 2001 From: Aman Verma <141578852+amanverma678@users.noreply.github.com> Date: Tue, 19 Nov 2024 16:01:44 +0530 Subject: [PATCH 10/48] fix: warnings --- locals.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locals.tf b/locals.tf index 64a31be..b7a0f45 100644 --- a/locals.tf +++ b/locals.tf @@ -11,5 +11,5 @@ locals { count = var.enabled ? 1 : 0 filename = "${path.module}/kubeconfig_generated" content = data.template_file.kubeconfig[0].rendered -} + } } \ No newline at end of file From eddfd0df2218c5affd5f3b06f6ff41ef794bbf7f Mon Sep 17 00:00:00 2001 From: Aman Verma <141578852+amanverma678@users.noreply.github.com> Date: Tue, 19 Nov 2024 16:08:07 +0530 Subject: [PATCH 11/48] fix: warnings --- locals.tf | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/locals.tf b/locals.tf index b7a0f45..c22166b 100644 --- a/locals.tf +++ b/locals.tf @@ -7,9 +7,4 @@ locals { aws_policy_prefix = format("arn:%s:iam::aws:policy", data.aws_partition.current.partition) create_outposts_local_cluster = length(var.outpost_config) > 0 - resource "local_file" "kubeconfig" { - count = var.enabled ? 1 : 0 - filename = "${path.module}/kubeconfig_generated" - content = data.template_file.kubeconfig[0].rendered - } -} \ No newline at end of file +} From 609398ac2202f4e57c9771a37c413743100f8a14 Mon Sep 17 00:00:00 2001 From: Aman Verma <141578852+amanverma678@users.noreply.github.com> Date: Tue, 19 Nov 2024 16:39:40 +0530 Subject: [PATCH 12/48] fix: warnings --- versions.tf | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/versions.tf b/versions.tf index 5e4bf85..8c08eed 100644 --- a/versions.tf +++ b/versions.tf @@ -7,21 +7,5 @@ terraform { source = "hashicorp/aws" version = ">= 5.11.0" } - template = { - source = "hashicorp/template" - version = ">= 2.2.0" # Update to the minimum required version - } - null = { - source = "hashicorp/null" - version = ">= 3.2.3" # Update to the minimum required version - } - kubernetes = { - source = "hashicorp/kubernetes" - version = ">= 2.33.0" # Update to the minimum required version - } - tls = { - source = "hashicorp/tls" - version = ">= 4.0.6" # Specify the appropriate version - } } } \ No newline at end of file From db2bf76359f5a67d59053fc53fddaf4553dd8572 Mon Sep 17 00:00:00 2001 From: Aman Verma <141578852+amanverma678@users.noreply.github.com> Date: Tue, 19 Nov 2024 16:42:07 +0530 Subject: [PATCH 13/48] fix: warnings --- examples/aws_managed/example.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/aws_managed/example.tf b/examples/aws_managed/example.tf index d06d76c..efed3f2 100644 --- a/examples/aws_managed/example.tf +++ b/examples/aws_managed/example.tf @@ -281,7 +281,7 @@ module "eks" { vpc_id = module.vpc.vpc_id subnet_ids = module.subnets.private_subnet_id allowed_security_groups = [module.ssh.security_group_id] - eks_additional_security_group_ids = module.ssh.security_group_id, module.http_https.security_group_id + eks_additional_security_group_ids = [module.ssh.security_group_id, module.http_https.security_group_id] allowed_cidr_blocks = [local.vpc_cidr_block] # AWS Managed Node Group From d9161b940d8fe2d7227e79adab6fdf45a47ffefc Mon Sep 17 00:00:00 2001 From: Aman Verma <141578852+amanverma678@users.noreply.github.com> Date: Tue, 19 Nov 2024 16:45:44 +0530 Subject: [PATCH 14/48] fix: warnings --- examples/aws_managed/example.tf | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/aws_managed/example.tf b/examples/aws_managed/example.tf index efed3f2..ca73c1f 100644 --- a/examples/aws_managed/example.tf +++ b/examples/aws_managed/example.tf @@ -54,8 +54,6 @@ module "subnets" { extra_private_tags = { "kubernetes.io/cluster/${module.eks.cluster_name}" = "owned" "kubernetes.io/role/internal-elb" = "1" - - tags = locals.tags } public_inbound_acl_rules = [ From a1a417e8e07a8d53996d385f7ec6b7f83f67626c Mon Sep 17 00:00:00 2001 From: Aman Verma <141578852+amanverma678@users.noreply.github.com> Date: Tue, 19 Nov 2024 16:54:54 +0530 Subject: [PATCH 15/48] fix: warnings --- examples/aws_managed_with_fargate/example.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/aws_managed_with_fargate/example.tf b/examples/aws_managed_with_fargate/example.tf index 93fe1a4..c9e04ff 100644 --- a/examples/aws_managed_with_fargate/example.tf +++ b/examples/aws_managed_with_fargate/example.tf @@ -280,7 +280,7 @@ module "eks" { vpc_id = module.vpc.vpc_id subnet_ids = module.subnets.private_subnet_id allowed_security_groups = [module.ssh.security_group_id] - eks_additional_security_group_ids = ["${module.ssh.security_group_id}", "${module.http_https.security_group_id}"] + eks_additional_security_group_ids = [module.ssh.security_group_id, module.http_https.security_group_id] allowed_cidr_blocks = [local.vpc_cidr_block] # AWS Managed Node Group From e3ba7c5a905caa9f52111d616a3924d6125e7464 Mon Sep 17 00:00:00 2001 From: Aman Verma <141578852+amanverma678@users.noreply.github.com> Date: Tue, 19 Nov 2024 16:58:59 +0530 Subject: [PATCH 16/48] fix: warnings --- examples/complete/example.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/complete/example.tf b/examples/complete/example.tf index 6754bbd..0b82138 100644 --- a/examples/complete/example.tf +++ b/examples/complete/example.tf @@ -277,7 +277,7 @@ module "eks" { vpc_id = module.vpc.vpc_id subnet_ids = module.subnets.private_subnet_id allowed_security_groups = [module.ssh.security_group_id] - eks_additional_security_group_ids = ["${module.ssh.security_group_id}", "${module.http_https.security_group_id}"] + eks_additional_security_group_ids = [module.ssh.security_group_id,module.http_https.security_group_id] allowed_cidr_blocks = [local.vpc_cidr_block] # Self Managed Node Group From c929c4183775800740a02cf68190e7b4fcbde0a8 Mon Sep 17 00:00:00 2001 From: Aman Verma <141578852+amanverma678@users.noreply.github.com> Date: Tue, 19 Nov 2024 17:36:43 +0530 Subject: [PATCH 17/48] fix: warnings --- versions.tf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/versions.tf b/versions.tf index 8c08eed..35500c8 100644 --- a/versions.tf +++ b/versions.tf @@ -7,5 +7,9 @@ terraform { source = "hashicorp/aws" version = ">= 5.11.0" } + kubernetes = { + source = "hashicorp/kubernetes" + version = ">= 2.33.0" # Specify the appropriate version + } } } \ No newline at end of file From 9ac218c39306d02a9961ca2060eb11f768ffd4ff Mon Sep 17 00:00:00 2001 From: Aman Verma <141578852+amanverma678@users.noreply.github.com> Date: Tue, 19 Nov 2024 17:49:38 +0530 Subject: [PATCH 18/48] fix: warnings --- versions.tf | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/versions.tf b/versions.tf index 35500c8..c189a68 100644 --- a/versions.tf +++ b/versions.tf @@ -1,15 +1,13 @@ # Terraform version terraform { required_version = ">= 1.5.4" + kubernetes = ">= 2.33.0" + } required_providers { aws = { source = "hashicorp/aws" version = ">= 5.11.0" } - kubernetes = { - source = "hashicorp/kubernetes" - version = ">= 2.33.0" # Specify the appropriate version - } } } \ No newline at end of file From b87a2dcef91a41c995045630be47f7bcc899d403 Mon Sep 17 00:00:00 2001 From: Aman Verma <141578852+amanverma678@users.noreply.github.com> Date: Tue, 19 Nov 2024 17:50:51 +0530 Subject: [PATCH 19/48] fix: warnings --- versions.tf | 1 - 1 file changed, 1 deletion(-) diff --git a/versions.tf b/versions.tf index c189a68..c28903c 100644 --- a/versions.tf +++ b/versions.tf @@ -2,7 +2,6 @@ terraform { required_version = ">= 1.5.4" kubernetes = ">= 2.33.0" - } required_providers { aws = { From 68c26202d6be1a6b648487d8f96cc8e8deac06d3 Mon Sep 17 00:00:00 2001 From: Aman Verma <141578852+amanverma678@users.noreply.github.com> Date: Tue, 19 Nov 2024 17:52:24 +0530 Subject: [PATCH 20/48] fix: warnings --- versions.tf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/versions.tf b/versions.tf index c28903c..35500c8 100644 --- a/versions.tf +++ b/versions.tf @@ -1,12 +1,15 @@ # Terraform version terraform { required_version = ">= 1.5.4" - kubernetes = ">= 2.33.0" required_providers { aws = { source = "hashicorp/aws" version = ">= 5.11.0" } + kubernetes = { + source = "hashicorp/kubernetes" + version = ">= 2.33.0" # Specify the appropriate version + } } } \ No newline at end of file From 8b25bc0cea9962a318690815274e4057881aaa09 Mon Sep 17 00:00:00 2001 From: Aman Verma <141578852+amanverma678@users.noreply.github.com> Date: Tue, 19 Nov 2024 18:01:40 +0530 Subject: [PATCH 21/48] fix: warnings --- examples/aws_managed/example.tf | 2 ++ examples/complete/example.tf | 2 ++ 2 files changed, 4 insertions(+) diff --git a/examples/aws_managed/example.tf b/examples/aws_managed/example.tf index ca73c1f..72c40e5 100644 --- a/examples/aws_managed/example.tf +++ b/examples/aws_managed/example.tf @@ -54,6 +54,8 @@ module "subnets" { extra_private_tags = { "kubernetes.io/cluster/${module.eks.cluster_name}" = "owned" "kubernetes.io/role/internal-elb" = "1" + + tags = local.tags } public_inbound_acl_rules = [ diff --git a/examples/complete/example.tf b/examples/complete/example.tf index 0b82138..769dac8 100644 --- a/examples/complete/example.tf +++ b/examples/complete/example.tf @@ -51,6 +51,8 @@ module "subnets" { extra_private_tags = { "kubernetes.io/cluster/${module.eks.cluster_name}" = "shared" "kubernetes.io/role/internal-elb" = "1" + + tags = local.tags } public_inbound_acl_rules = [ From 730c701d0bfed4975bbe25637c971e93086926a1 Mon Sep 17 00:00:00 2001 From: Aman Verma <141578852+amanverma678@users.noreply.github.com> Date: Tue, 19 Nov 2024 18:03:37 +0530 Subject: [PATCH 22/48] fix: warnings --- examples/aws_managed/example.tf | 1 - examples/aws_managed_with_fargate/example.tf | 1 + examples/complete/example.tf | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/aws_managed/example.tf b/examples/aws_managed/example.tf index 72c40e5..b01f578 100644 --- a/examples/aws_managed/example.tf +++ b/examples/aws_managed/example.tf @@ -54,7 +54,6 @@ module "subnets" { extra_private_tags = { "kubernetes.io/cluster/${module.eks.cluster_name}" = "owned" "kubernetes.io/role/internal-elb" = "1" - tags = local.tags } diff --git a/examples/aws_managed_with_fargate/example.tf b/examples/aws_managed_with_fargate/example.tf index c9e04ff..cb37937 100644 --- a/examples/aws_managed_with_fargate/example.tf +++ b/examples/aws_managed_with_fargate/example.tf @@ -54,6 +54,7 @@ module "subnets" { extra_private_tags = { "kubernetes.io/cluster/${module.eks.cluster_name}" = "owned" "kubernetes.io/role/internal-elb" = "1" + tags = local.tags } public_inbound_acl_rules = [ diff --git a/examples/complete/example.tf b/examples/complete/example.tf index 769dac8..debce5f 100644 --- a/examples/complete/example.tf +++ b/examples/complete/example.tf @@ -51,7 +51,6 @@ module "subnets" { extra_private_tags = { "kubernetes.io/cluster/${module.eks.cluster_name}" = "shared" "kubernetes.io/role/internal-elb" = "1" - tags = local.tags } From 8370c8c5e886c3bf5266db6be04a4e8d5f3d6291 Mon Sep 17 00:00:00 2001 From: Aman Verma <141578852+amanverma678@users.noreply.github.com> Date: Tue, 19 Nov 2024 18:07:10 +0530 Subject: [PATCH 23/48] fix: warnings --- examples/self_managed/example.tf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/self_managed/example.tf b/examples/self_managed/example.tf index d6556de..602a7c7 100644 --- a/examples/self_managed/example.tf +++ b/examples/self_managed/example.tf @@ -50,6 +50,7 @@ module "subnets" { extra_private_tags = { "kubernetes.io/cluster/${module.eks.cluster_name}" = "shared" "kubernetes.io/role/internal-elb" = "1" + tags = local.tags } public_inbound_acl_rules = [ @@ -237,7 +238,7 @@ module "eks" { vpc_id = module.vpc.vpc_id subnet_ids = module.subnets.private_subnet_id allowed_security_groups = [module.ssh.security_group_id] - eks_additional_security_group_ids = ["${module.ssh.security_group_id}", "${module.http_https.security_group_id}"] + eks_additional_security_group_ids = [module.ssh.security_group_id , module.http_https.security_group_id] allowed_cidr_blocks = [local.vpc_cidr_block] # Self Managed Node Grou From 579721f846322eadf9061915662d27e02ec0a6a0 Mon Sep 17 00:00:00 2001 From: Aman Verma <141578852+amanverma678@users.noreply.github.com> Date: Tue, 19 Nov 2024 18:19:15 +0530 Subject: [PATCH 24/48] fix: warnings --- examples/self_managed/example.tf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/self_managed/example.tf b/examples/self_managed/example.tf index 602a7c7..75514f6 100644 --- a/examples/self_managed/example.tf +++ b/examples/self_managed/example.tf @@ -41,6 +41,7 @@ module "subnets" { ipv6_cidr_block = module.vpc.ipv6_cidr_block type = "public-private" igw_id = module.vpc.igw_id + label_order = local.label_order extra_public_tags = { "kubernetes.io/cluster/${module.eks.cluster_name}" = "shared" @@ -51,6 +52,7 @@ module "subnets" { "kubernetes.io/cluster/${module.eks.cluster_name}" = "shared" "kubernetes.io/role/internal-elb" = "1" tags = local.tags + } public_inbound_acl_rules = [ From a165cdc68f0596a0c1ff31933461d8b5a1a3b213 Mon Sep 17 00:00:00 2001 From: Aman Verma <141578852+amanverma678@users.noreply.github.com> Date: Tue, 19 Nov 2024 19:44:15 +0530 Subject: [PATCH 25/48] fix: warnings --- node_group/aws_managed/main.tf | 1 + node_group/self_managed/main.tf | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/node_group/aws_managed/main.tf b/node_group/aws_managed/main.tf index 650ecdf..9930375 100644 --- a/node_group/aws_managed/main.tf +++ b/node_group/aws_managed/main.tf @@ -40,6 +40,7 @@ resource "aws_launch_template" "this" { disable_api_termination = var.disable_api_termination kernel_id = var.kernel_id ram_disk_id = var.ram_disk_id + default_version = var.launch_template_default_version dynamic "block_device_mappings" { for_each = var.block_device_mappings diff --git a/node_group/self_managed/main.tf b/node_group/self_managed/main.tf index e16208a..1012981 100644 --- a/node_group/self_managed/main.tf +++ b/node_group/self_managed/main.tf @@ -1,7 +1,7 @@ locals { self_managed_node_group_default_tags = { - "Name" = "${module.labels.id}" - "Environment" = "${var.environment}" + "Name" = [module.labels.id] + "Environment" = [var.environment] "kubernetes.io/cluster/${var.cluster_name}" = "owned" "k8s.io/cluster/${var.cluster_name}" = "owned" } From 7059cf68af16e285959bd4caa14d245802a18c7e Mon Sep 17 00:00:00 2001 From: amanverma678 Date: Tue, 19 Nov 2024 22:24:08 +0530 Subject: [PATCH 26/48] fix: warnings --- versions.tf | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/versions.tf b/versions.tf index 35500c8..23b1900 100644 --- a/versions.tf +++ b/versions.tf @@ -11,5 +11,13 @@ terraform { source = "hashicorp/kubernetes" version = ">= 2.33.0" # Specify the appropriate version } + template = { + source = "hashicorp/template" + version = ">= 2.2.0" + } + null = { + source = "hashicorp/null" + version = ">= 3.0.0" + } } } \ No newline at end of file From 62b4efa559079acd471751a6a7dcf979c64318ce Mon Sep 17 00:00:00 2001 From: amanverma678 Date: Tue, 19 Nov 2024 22:31:45 +0530 Subject: [PATCH 27/48] fix: warnings --- examples/aws_managed/versions.tf | 11 +++++++++++ examples/aws_managed_with_fargate/versions.tf | 11 +++++++++++ examples/complete/versions.tf | 11 +++++++++++ 3 files changed, 33 insertions(+) diff --git a/examples/aws_managed/versions.tf b/examples/aws_managed/versions.tf index 1534170..541632e 100644 --- a/examples/aws_managed/versions.tf +++ b/examples/aws_managed/versions.tf @@ -11,5 +11,16 @@ terraform { source = "hashicorp/cloudinit" version = ">= 2.0" } + kubernetes = { + source = "hashicorp/kubernetes" + version = ">= 2.33.0" # Specify the appropriate version + } + template = { + source = "hashicorp/template" + version = ">= 2.2.0" + } + null = { + source = "hashicorp/null" + version = ">= 3.0.0" } } \ No newline at end of file diff --git a/examples/aws_managed_with_fargate/versions.tf b/examples/aws_managed_with_fargate/versions.tf index 1534170..541632e 100644 --- a/examples/aws_managed_with_fargate/versions.tf +++ b/examples/aws_managed_with_fargate/versions.tf @@ -11,5 +11,16 @@ terraform { source = "hashicorp/cloudinit" version = ">= 2.0" } + kubernetes = { + source = "hashicorp/kubernetes" + version = ">= 2.33.0" # Specify the appropriate version + } + template = { + source = "hashicorp/template" + version = ">= 2.2.0" + } + null = { + source = "hashicorp/null" + version = ">= 3.0.0" } } \ No newline at end of file diff --git a/examples/complete/versions.tf b/examples/complete/versions.tf index 1534170..541632e 100644 --- a/examples/complete/versions.tf +++ b/examples/complete/versions.tf @@ -11,5 +11,16 @@ terraform { source = "hashicorp/cloudinit" version = ">= 2.0" } + kubernetes = { + source = "hashicorp/kubernetes" + version = ">= 2.33.0" # Specify the appropriate version + } + template = { + source = "hashicorp/template" + version = ">= 2.2.0" + } + null = { + source = "hashicorp/null" + version = ">= 3.0.0" } } \ No newline at end of file From d7c6c6c4f9edee562e1f4436df923f0c72f0b7ff Mon Sep 17 00:00:00 2001 From: amanverma678 Date: Tue, 19 Nov 2024 22:36:12 +0530 Subject: [PATCH 28/48] fix: warnings --- examples/aws_managed/versions.tf | 1 + examples/aws_managed_with_fargate/versions.tf | 1 + examples/complete/versions.tf | 1 + 3 files changed, 3 insertions(+) diff --git a/examples/aws_managed/versions.tf b/examples/aws_managed/versions.tf index 541632e..881cb7e 100644 --- a/examples/aws_managed/versions.tf +++ b/examples/aws_managed/versions.tf @@ -22,5 +22,6 @@ terraform { null = { source = "hashicorp/null" version = ">= 3.0.0" + } } } \ No newline at end of file diff --git a/examples/aws_managed_with_fargate/versions.tf b/examples/aws_managed_with_fargate/versions.tf index 541632e..881cb7e 100644 --- a/examples/aws_managed_with_fargate/versions.tf +++ b/examples/aws_managed_with_fargate/versions.tf @@ -22,5 +22,6 @@ terraform { null = { source = "hashicorp/null" version = ">= 3.0.0" + } } } \ No newline at end of file diff --git a/examples/complete/versions.tf b/examples/complete/versions.tf index 541632e..881cb7e 100644 --- a/examples/complete/versions.tf +++ b/examples/complete/versions.tf @@ -22,5 +22,6 @@ terraform { null = { source = "hashicorp/null" version = ">= 3.0.0" + } } } \ No newline at end of file From 84d56fad13a49a7e3587042a43733aaff063ece0 Mon Sep 17 00:00:00 2001 From: amanverma678 Date: Tue, 19 Nov 2024 23:04:54 +0530 Subject: [PATCH 29/48] fix: warnings --- node_group/fargate_profile/fargate.tf | 1 + 1 file changed, 1 insertion(+) diff --git a/node_group/fargate_profile/fargate.tf b/node_group/fargate_profile/fargate.tf index 5f2bda3..a1baa9c 100644 --- a/node_group/fargate_profile/fargate.tf +++ b/node_group/fargate_profile/fargate.tf @@ -1,4 +1,5 @@ terraform { + required_version = ">= 1.5.4" required_providers { aws = { source = "hashicorp/aws" From c50481c741396e92d0edc43db5452567d9ef8697 Mon Sep 17 00:00:00 2001 From: amanverma678 Date: Tue, 19 Nov 2024 23:26:17 +0530 Subject: [PATCH 30/48] fix: warnings --- node_group/aws_managed/main.tf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/node_group/aws_managed/main.tf b/node_group/aws_managed/main.tf index 9930375..50db7e8 100644 --- a/node_group/aws_managed/main.tf +++ b/node_group/aws_managed/main.tf @@ -40,7 +40,8 @@ resource "aws_launch_template" "this" { disable_api_termination = var.disable_api_termination kernel_id = var.kernel_id ram_disk_id = var.ram_disk_id - default_version = var.launch_template_default_version + default_version = var.update_launch_template_default_version ? var.launch_template_default_version : null + dynamic "block_device_mappings" { for_each = var.block_device_mappings From f69b2ee28e1eecb4d8822a4a1e663ef7cdc454a7 Mon Sep 17 00:00:00 2001 From: amanverma678 Date: Tue, 19 Nov 2024 23:32:32 +0530 Subject: [PATCH 31/48] fix: warnings --- examples/self_managed/example.tf | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/self_managed/example.tf b/examples/self_managed/example.tf index 75514f6..6b1f3a3 100644 --- a/examples/self_managed/example.tf +++ b/examples/self_managed/example.tf @@ -1,6 +1,11 @@ provider "aws" { region = local.region + kubernetes { + source = "hashicorp/kubernetes" + version = ">= 2.33.0" # Specify the appropriate version + } } + locals { name = "clouddrove-eks" region = "eu-west-1" From fbb9cc9a499f6d8c7e6edf711b94e62952b3c19f Mon Sep 17 00:00:00 2001 From: amanverma678 Date: Tue, 19 Nov 2024 23:37:49 +0530 Subject: [PATCH 32/48] fix: warnings --- examples/self_managed/example.tf | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/self_managed/example.tf b/examples/self_managed/example.tf index 6b1f3a3..54e6b5e 100644 --- a/examples/self_managed/example.tf +++ b/examples/self_managed/example.tf @@ -1,11 +1,13 @@ -provider "aws" { - region = local.region - kubernetes { +terraform { + required_version = ">= 1.5.4" + kubernetes = { source = "hashicorp/kubernetes" version = ">= 2.33.0" # Specify the appropriate version } + } +provider "aws" { + region = local.region } - locals { name = "clouddrove-eks" region = "eu-west-1" From 36e626f9a41faf794914215d375ea40c26b97ca4 Mon Sep 17 00:00:00 2001 From: amanverma678 Date: Tue, 26 Nov 2024 16:55:07 +0530 Subject: [PATCH 33/48] Fix: warnings --- examples/aws_managed/example.tf | 19 ++++++++++++++-- examples/aws_managed_with_fargate/example.tf | 2 +- examples/complete/example.tf | 2 +- examples/self_managed/example.tf | 11 +++------- examples/self_managed/versions.tf | 8 +++++++ main.tf | 4 ++-- node_group/aws_managed/main.tf | 8 +++---- node_group/aws_managed/variables.tf | 4 ++-- node_group/fargate_profile/fargate.tf | 1 + node_group/self_managed/main.tf | 10 +++++---- node_group/self_managed/versions.tf | 23 ++++++++++++++++++++ outputs.tf | 5 +++++ versions.tf | 4 ++++ 13 files changed, 76 insertions(+), 25 deletions(-) create mode 100644 node_group/self_managed/versions.tf diff --git a/examples/aws_managed/example.tf b/examples/aws_managed/example.tf index b01f578..f349531 100644 --- a/examples/aws_managed/example.tf +++ b/examples/aws_managed/example.tf @@ -54,7 +54,6 @@ module "subnets" { extra_private_tags = { "kubernetes.io/cluster/${module.eks.cluster_name}" = "owned" "kubernetes.io/role/internal-elb" = "1" - tags = local.tags } public_inbound_acl_rules = [ @@ -272,6 +271,7 @@ module "eks" { name = local.name environment = local.environment label_order = local.label_order + tags = local.tags # EKS kubernetes_version = "1.27" @@ -291,7 +291,22 @@ module "eks" { tags = { "kubernetes.io/cluster/${module.eks.cluster_name}" = "shared" "k8s.io/cluster/${module.eks.cluster_name}" = "shared" + propagate_tags = [{ + key = "aws-node-termination-handler/managed" + value = true + propagate_at_launch = true + }, + { + key = "autoscaling:ResourceTag/k8s.io/cluster-autoscaler/${module.eks.cluster_id}" + value = "owned" + propagate_at_launch = true + }] } + propagate_tags = [{ + key = "aws-node-termination-handler/managed" + value = true + propagate_at_launch = true + }] block_device_mappings = { xvda = { device_name = "/dev/xvda" @@ -351,4 +366,4 @@ provider "kubernetes" { host = data.aws_eks_cluster.this.endpoint cluster_ca_certificate = base64decode(data.aws_eks_cluster.this.certificate_authority[0].data) token = data.aws_eks_cluster_auth.this.token -} +} \ No newline at end of file diff --git a/examples/aws_managed_with_fargate/example.tf b/examples/aws_managed_with_fargate/example.tf index cb37937..e952b1a 100644 --- a/examples/aws_managed_with_fargate/example.tf +++ b/examples/aws_managed_with_fargate/example.tf @@ -54,7 +54,6 @@ module "subnets" { extra_private_tags = { "kubernetes.io/cluster/${module.eks.cluster_name}" = "owned" "kubernetes.io/role/internal-elb" = "1" - tags = local.tags } public_inbound_acl_rules = [ @@ -273,6 +272,7 @@ module "eks" { name = local.name environment = local.environment label_order = local.label_order + tags = local.tags # EKS kubernetes_version = "1.27" diff --git a/examples/complete/example.tf b/examples/complete/example.tf index debce5f..15b0133 100644 --- a/examples/complete/example.tf +++ b/examples/complete/example.tf @@ -51,7 +51,6 @@ module "subnets" { extra_private_tags = { "kubernetes.io/cluster/${module.eks.cluster_name}" = "shared" "kubernetes.io/role/internal-elb" = "1" - tags = local.tags } public_inbound_acl_rules = [ @@ -269,6 +268,7 @@ module "eks" { name = local.name environment = local.environment enabled = true + tags = local.tags kubernetes_version = "1.27" endpoint_private_access = true diff --git a/examples/self_managed/example.tf b/examples/self_managed/example.tf index 54e6b5e..0aae6ca 100644 --- a/examples/self_managed/example.tf +++ b/examples/self_managed/example.tf @@ -1,9 +1,5 @@ terraform { required_version = ">= 1.5.4" - kubernetes = { - source = "hashicorp/kubernetes" - version = ">= 2.33.0" # Specify the appropriate version - } } provider "aws" { region = local.region @@ -58,8 +54,6 @@ module "subnets" { extra_private_tags = { "kubernetes.io/cluster/${module.eks.cluster_name}" = "shared" "kubernetes.io/role/internal-elb" = "1" - tags = local.tags - } public_inbound_acl_rules = [ @@ -238,6 +232,9 @@ module "eks" { name = local.name environment = "test" + tags = local.tags + +data "aws_caller_identity" "current" {} # EKS kubernetes_version = "1.27" @@ -262,8 +259,6 @@ module "eks" { { key = "autoscaling:ResourceTag/k8s.io/cluster-autoscaler/${module.eks.cluster_id}" value = "owned" - propagate_at_launch = true - } ] diff --git a/examples/self_managed/versions.tf b/examples/self_managed/versions.tf index bc7a027..7ce3d42 100644 --- a/examples/self_managed/versions.tf +++ b/examples/self_managed/versions.tf @@ -10,5 +10,13 @@ terraform { source = "hashicorp/cloudinit" version = ">= 2.0" } + kubernetes = { + source = "hashicorp/kubernetes" + version = ">= 2.33.0" # Specify the appropriate version + } + template = { + source = "hashicorp/template" + version = ">= 2.2.0" + } } } \ No newline at end of file diff --git a/main.tf b/main.tf index 547f6ec..58fd8f8 100644 --- a/main.tf +++ b/main.tf @@ -44,9 +44,9 @@ resource "aws_eks_cluster" "default" { dynamic "encryption_config" { for_each = var.cluster_encryption_config_enabled ? [local.cluster_encryption_config] : [] content { - resources = lookup(encryption_config.value, "resources") + resources = lookup(encryption_config.value, "resources", null) provider { - key_arn = lookup(encryption_config.value, "provider_key_arn") + key_arn = lookup(encryption_config.value, "provider_key_arn", null) } } } diff --git a/node_group/aws_managed/main.tf b/node_group/aws_managed/main.tf index 50db7e8..5a6ed31 100644 --- a/node_group/aws_managed/main.tf +++ b/node_group/aws_managed/main.tf @@ -1,6 +1,3 @@ -data "aws_partition" "current" {} - -data "aws_caller_identity" "current" {} #Module : label #Description : Terraform module to create consistent naming for multiple names. @@ -36,11 +33,12 @@ resource "aws_launch_template" "this" { key_name = var.key_name user_data = var.before_cluster_joining_userdata vpc_security_group_ids = var.vpc_security_group_ids - + instance_market_options = var.instance_market_options disable_api_termination = var.disable_api_termination kernel_id = var.kernel_id ram_disk_id = var.ram_disk_id default_version = var.update_launch_template_default_version ? var.launch_template_default_version : null + launch_template_tags = var.launch_template_tags dynamic "block_device_mappings" { @@ -246,7 +244,7 @@ resource "aws_eks_node_group" "this" { for_each = var.taints content { key = taint.value.key - value = lookup(taint.value, "value") + value = lookup(taint.value, "value", null) effect = taint.value.effect } } diff --git a/node_group/aws_managed/variables.tf b/node_group/aws_managed/variables.tf index 0b10f6d..7d9c00e 100644 --- a/node_group/aws_managed/variables.tf +++ b/node_group/aws_managed/variables.tf @@ -96,7 +96,7 @@ variable "launch_template_default_version" { variable "update_launch_template_default_version" { description = "Whether to update the launch templates default version on each update. Conflicts with `launch_template_default_version`" type = bool - default = true + default = false } variable "disable_api_termination" { @@ -162,7 +162,7 @@ variable "enclave_options" { variable "instance_market_options" { description = "The market (purchasing) option for the instance" type = any - default = null + default = true } variable "license_specifications" { diff --git a/node_group/fargate_profile/fargate.tf b/node_group/fargate_profile/fargate.tf index a1baa9c..e69e3cc 100644 --- a/node_group/fargate_profile/fargate.tf +++ b/node_group/fargate_profile/fargate.tf @@ -20,6 +20,7 @@ module "labels" { delimiter = var.delimiter attributes = compact(concat(var.attributes, ["fargate"])) label_order = var.label_order + tags = var.tags } diff --git a/node_group/self_managed/main.tf b/node_group/self_managed/main.tf index 1012981..59e8a2c 100644 --- a/node_group/self_managed/main.tf +++ b/node_group/self_managed/main.tf @@ -7,10 +7,6 @@ locals { } } -data "aws_partition" "current" {} - -data "aws_caller_identity" "current" {} - #AMI AMAZON LINUX data "aws_ami" "eks_default" { @@ -34,6 +30,12 @@ data "template_file" "userdata" { certificate_authority_data = var.cluster_auth_base64 cluster_name = var.cluster_name bootstrap_extra_args = var.bootstrap_extra_args + cluster_service_ipv4_cidr = var.cluster_service_ipv4_cidr + pre_bootstrap_user_data = var.pre_bootstrap_user_data + post_bootstrap_user_data = var.post_bootstrap_user_data + delete_timeout = var.delete_timeout + propagate_tags = var.propagate_tags + } } diff --git a/node_group/self_managed/versions.tf b/node_group/self_managed/versions.tf new file mode 100644 index 0000000..1596cfc --- /dev/null +++ b/node_group/self_managed/versions.tf @@ -0,0 +1,23 @@ +# Terraform version +terraform { + required_version = ">= 1.5.4" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.11.0" + } + kubernetes = { + source = "hashicorp/kubernetes" + version = ">= 2.33.0" # Specify the appropriate version + } + template = { + source = "hashicorp/template" + version = ">= 2.2.0" + } + tls = { + source = "hashicorp/tls" + version = "~> 4.0" + } + } +} \ No newline at end of file diff --git a/outputs.tf b/outputs.tf index 5f9778c..f90746b 100644 --- a/outputs.tf +++ b/outputs.tf @@ -89,4 +89,9 @@ output "tags" { output "cluster_name" { value = module.labels.id +} + +output "kubeconfig" { + description = "kubectl config file contents for this EKS cluster." + value = data.template_file.kubeconfig } \ No newline at end of file diff --git a/versions.tf b/versions.tf index 23b1900..28c2813 100644 --- a/versions.tf +++ b/versions.tf @@ -19,5 +19,9 @@ terraform { source = "hashicorp/null" version = ">= 3.0.0" } + tls = { + source = "hashicorp/tls" + version = "~> 4.0" # Or specify the version you want to use + } } } \ No newline at end of file From 050629e8d70862aa260c585022fe01c275135c1b Mon Sep 17 00:00:00 2001 From: amanverma678 Date: Tue, 26 Nov 2024 16:55:46 +0530 Subject: [PATCH 34/48] Fix: warnings --- node_group/self_managed/main.tf | 2 -- 1 file changed, 2 deletions(-) diff --git a/node_group/self_managed/main.tf b/node_group/self_managed/main.tf index 59e8a2c..b51841f 100644 --- a/node_group/self_managed/main.tf +++ b/node_group/self_managed/main.tf @@ -35,8 +35,6 @@ data "template_file" "userdata" { post_bootstrap_user_data = var.post_bootstrap_user_data delete_timeout = var.delete_timeout propagate_tags = var.propagate_tags - - } } #Module : label From d4a1bbf059c985c236c5e00b0796c1eebe0e0997 Mon Sep 17 00:00:00 2001 From: amanverma678 Date: Tue, 26 Nov 2024 17:00:43 +0530 Subject: [PATCH 35/48] Fix: warnings --- node_group/fargate_profile/variables.tf | 6 ------ 1 file changed, 6 deletions(-) diff --git a/node_group/fargate_profile/variables.tf b/node_group/fargate_profile/variables.tf index 3b71b02..225a55e 100644 --- a/node_group/fargate_profile/variables.tf +++ b/node_group/fargate_profile/variables.tf @@ -24,12 +24,6 @@ variable "attributes" { description = "Additional attributes (e.g. `1`)." } -variable "tags" { - type = map(any) - default = {} - description = "Additional tags (e.g. map(`BusinessUnit`,`XYZ`)." -} - variable "managedby" { type = string default = "hello@clouddorve.com" From f37ce364cb16dcdac3da260f5d6508d2b8ee0249 Mon Sep 17 00:00:00 2001 From: amanverma678 Date: Tue, 26 Nov 2024 17:02:34 +0530 Subject: [PATCH 36/48] Fix: warnings --- node_group/fargate_profile/fargate.tf | 1 - 1 file changed, 1 deletion(-) diff --git a/node_group/fargate_profile/fargate.tf b/node_group/fargate_profile/fargate.tf index e69e3cc..a1baa9c 100644 --- a/node_group/fargate_profile/fargate.tf +++ b/node_group/fargate_profile/fargate.tf @@ -20,7 +20,6 @@ module "labels" { delimiter = var.delimiter attributes = compact(concat(var.attributes, ["fargate"])) label_order = var.label_order - tags = var.tags } From 21169f280553922f5e7da54009505268151fc6d1 Mon Sep 17 00:00:00 2001 From: amanverma678 Date: Tue, 26 Nov 2024 17:41:47 +0530 Subject: [PATCH 37/48] Fix: warnings --- node_group/aws_managed/main.tf | 20 +++++++++++++++----- node_group/self_managed/main.tf | 5 ++++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/node_group/aws_managed/main.tf b/node_group/aws_managed/main.tf index 5a6ed31..0164918 100644 --- a/node_group/aws_managed/main.tf +++ b/node_group/aws_managed/main.tf @@ -26,20 +26,30 @@ resource "aws_launch_template" "this" { name = module.labels.id description = var.launch_template_description - ebs_optimized = var.ebs_optimized - image_id = var.ami_id + ebs_optimized = var.ebs_optimized + image_id = var.ami_id # # Set on node group instead # instance_type = var.launch_template_instance_type key_name = var.key_name user_data = var.before_cluster_joining_userdata vpc_security_group_ids = var.vpc_security_group_ids - instance_market_options = var.instance_market_options disable_api_termination = var.disable_api_termination kernel_id = var.kernel_id ram_disk_id = var.ram_disk_id - default_version = var.update_launch_template_default_version ? var.launch_template_default_version : null - launch_template_tags = var.launch_template_tags + default_version = var.update_launch_template_default_version ? var.launch_template_default_version : null + tag_specifications { + resource_type = "instance" + tags = var.launch_template_tags + } + + instance_market_options { + market_type = var.instance_market_options.market_type + + spot_options { + max_price = var.instance_market_options.spot_options.max_price + } + } dynamic "block_device_mappings" { for_each = var.block_device_mappings diff --git a/node_group/self_managed/main.tf b/node_group/self_managed/main.tf index b51841f..db5804a 100644 --- a/node_group/self_managed/main.tf +++ b/node_group/self_managed/main.tf @@ -34,7 +34,10 @@ data "template_file" "userdata" { pre_bootstrap_user_data = var.pre_bootstrap_user_data post_bootstrap_user_data = var.post_bootstrap_user_data delete_timeout = var.delete_timeout - propagate_tags = var.propagate_tags + tags = flatten([for tag in var.propagate_tags : { + key = tag["key"] + value = tag["value"] + }]) } } #Module : label From 4aa0dac6a3a6e977edbacf55d5e85055092c3228 Mon Sep 17 00:00:00 2001 From: amanverma678 Date: Fri, 29 Nov 2024 22:11:58 +0530 Subject: [PATCH 38/48] fix: format --- examples/aws_managed/example.tf | 20 ++++++++++---------- examples/aws_managed_with_fargate/example.tf | 2 +- examples/complete/example.tf | 4 ++-- examples/self_managed/example.tf | 12 ++++++------ node_group/aws_managed/main.tf | 12 ++++++------ node_group/self_managed/main.tf | 6 +++--- versions.tf | 2 +- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/examples/aws_managed/example.tf b/examples/aws_managed/example.tf index f349531..3c4a940 100644 --- a/examples/aws_managed/example.tf +++ b/examples/aws_managed/example.tf @@ -271,7 +271,7 @@ module "eks" { name = local.name environment = local.environment label_order = local.label_order - tags = local.tags + tags = local.tags # EKS kubernetes_version = "1.27" @@ -291,22 +291,22 @@ module "eks" { tags = { "kubernetes.io/cluster/${module.eks.cluster_name}" = "shared" "k8s.io/cluster/${module.eks.cluster_name}" = "shared" - propagate_tags = [{ - key = "aws-node-termination-handler/managed" - value = true - propagate_at_launch = true - }, - { - key = "autoscaling:ResourceTag/k8s.io/cluster-autoscaler/${module.eks.cluster_id}" - value = "owned" + propagate_tags = [{ + key = "aws-node-termination-handler/managed" + value = true propagate_at_launch = true + }, + { + key = "autoscaling:ResourceTag/k8s.io/cluster-autoscaler/${module.eks.cluster_id}" + value = "owned" + propagate_at_launch = true }] } propagate_tags = [{ key = "aws-node-termination-handler/managed" value = true propagate_at_launch = true - }] + }] block_device_mappings = { xvda = { device_name = "/dev/xvda" diff --git a/examples/aws_managed_with_fargate/example.tf b/examples/aws_managed_with_fargate/example.tf index e952b1a..f8bc0ff 100644 --- a/examples/aws_managed_with_fargate/example.tf +++ b/examples/aws_managed_with_fargate/example.tf @@ -272,7 +272,7 @@ module "eks" { name = local.name environment = local.environment label_order = local.label_order - tags = local.tags + tags = local.tags # EKS kubernetes_version = "1.27" diff --git a/examples/complete/example.tf b/examples/complete/example.tf index 15b0133..6d43137 100644 --- a/examples/complete/example.tf +++ b/examples/complete/example.tf @@ -268,7 +268,7 @@ module "eks" { name = local.name environment = local.environment enabled = true - tags = local.tags + tags = local.tags kubernetes_version = "1.27" endpoint_private_access = true @@ -278,7 +278,7 @@ module "eks" { vpc_id = module.vpc.vpc_id subnet_ids = module.subnets.private_subnet_id allowed_security_groups = [module.ssh.security_group_id] - eks_additional_security_group_ids = [module.ssh.security_group_id,module.http_https.security_group_id] + eks_additional_security_group_ids = [module.ssh.security_group_id, module.http_https.security_group_id] allowed_cidr_blocks = [local.vpc_cidr_block] # Self Managed Node Group diff --git a/examples/self_managed/example.tf b/examples/self_managed/example.tf index 0aae6ca..98aab69 100644 --- a/examples/self_managed/example.tf +++ b/examples/self_managed/example.tf @@ -1,6 +1,6 @@ terraform { required_version = ">= 1.5.4" - } +} provider "aws" { region = local.region } @@ -232,9 +232,9 @@ module "eks" { name = local.name environment = "test" - tags = local.tags + tags = local.tags -data "aws_caller_identity" "current" {} + data "aws_caller_identity" "current" {} # EKS kubernetes_version = "1.27" @@ -244,7 +244,7 @@ data "aws_caller_identity" "current" {} vpc_id = module.vpc.vpc_id subnet_ids = module.subnets.private_subnet_id allowed_security_groups = [module.ssh.security_group_id] - eks_additional_security_group_ids = [module.ssh.security_group_id , module.http_https.security_group_id] + eks_additional_security_group_ids = [module.ssh.security_group_id, module.http_https.security_group_id] allowed_cidr_blocks = [local.vpc_cidr_block] # Self Managed Node Grou @@ -257,8 +257,8 @@ data "aws_caller_identity" "current" {} propagate_at_launch = true }, { - key = "autoscaling:ResourceTag/k8s.io/cluster-autoscaler/${module.eks.cluster_id}" - value = "owned" + key = "autoscaling:ResourceTag/k8s.io/cluster-autoscaler/${module.eks.cluster_id}" + value = "owned" } ] diff --git a/node_group/aws_managed/main.tf b/node_group/aws_managed/main.tf index 0164918..048d769 100644 --- a/node_group/aws_managed/main.tf +++ b/node_group/aws_managed/main.tf @@ -26,13 +26,13 @@ resource "aws_launch_template" "this" { name = module.labels.id description = var.launch_template_description - ebs_optimized = var.ebs_optimized - image_id = var.ami_id + ebs_optimized = var.ebs_optimized + image_id = var.ami_id # # Set on node group instead # instance_type = var.launch_template_instance_type - key_name = var.key_name - user_data = var.before_cluster_joining_userdata - vpc_security_group_ids = var.vpc_security_group_ids + key_name = var.key_name + user_data = var.before_cluster_joining_userdata + vpc_security_group_ids = var.vpc_security_group_ids disable_api_termination = var.disable_api_termination kernel_id = var.kernel_id ram_disk_id = var.ram_disk_id @@ -45,7 +45,7 @@ resource "aws_launch_template" "this" { instance_market_options { market_type = var.instance_market_options.market_type - + spot_options { max_price = var.instance_market_options.spot_options.max_price } diff --git a/node_group/self_managed/main.tf b/node_group/self_managed/main.tf index db5804a..bd664a7 100644 --- a/node_group/self_managed/main.tf +++ b/node_group/self_managed/main.tf @@ -35,9 +35,9 @@ data "template_file" "userdata" { post_bootstrap_user_data = var.post_bootstrap_user_data delete_timeout = var.delete_timeout tags = flatten([for tag in var.propagate_tags : { - key = tag["key"] - value = tag["value"] - }]) + key = tag["key"] + value = tag["value"] + }]) } } #Module : label diff --git a/versions.tf b/versions.tf index 28c2813..05dafb2 100644 --- a/versions.tf +++ b/versions.tf @@ -20,7 +20,7 @@ terraform { version = ">= 3.0.0" } tls = { - source = "hashicorp/tls" + source = "hashicorp/tls" version = "~> 4.0" # Or specify the version you want to use } } From e5e9247c4af147d63df2c489da351cfebef13d52 Mon Sep 17 00:00:00 2001 From: amanverma678 Date: Fri, 29 Nov 2024 22:26:01 +0530 Subject: [PATCH 39/48] fix: format --- examples/self_managed/example.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/self_managed/example.tf b/examples/self_managed/example.tf index 98aab69..4a06da0 100644 --- a/examples/self_managed/example.tf +++ b/examples/self_managed/example.tf @@ -234,7 +234,7 @@ module "eks" { environment = "test" tags = local.tags - data "aws_caller_identity" "current" {} + # EKS kubernetes_version = "1.27" From 9b3004c06165198a73ae97ccf15f38b9097ab661 Mon Sep 17 00:00:00 2001 From: amanverma678 Date: Fri, 29 Nov 2024 22:28:50 +0530 Subject: [PATCH 40/48] fix: format --- examples/self_managed/example.tf | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/self_managed/example.tf b/examples/self_managed/example.tf index 4a06da0..34b7dd8 100644 --- a/examples/self_managed/example.tf +++ b/examples/self_managed/example.tf @@ -234,8 +234,6 @@ module "eks" { environment = "test" tags = local.tags - - # EKS kubernetes_version = "1.27" endpoint_private_access = true From af8e7f9141699135e405a88c0c478f0a7db323e5 Mon Sep 17 00:00:00 2001 From: amanverma678 Date: Thu, 5 Dec 2024 23:59:10 +0530 Subject: [PATCH 41/48] Fix: variables --- main.tf | 1 + node_group/aws_managed/main.tf | 23 +++++++++++++++-------- node_group/fargate_profile/fargate.tf | 2 +- node_group/fargate_profile/variables.tf | 6 ++++++ variables.tf | 16 +++++----------- 5 files changed, 28 insertions(+), 20 deletions(-) diff --git a/main.tf b/main.tf index 58fd8f8..33c1421 100644 --- a/main.tf +++ b/main.tf @@ -39,6 +39,7 @@ resource "aws_eks_cluster" "default" { endpoint_public_access = var.endpoint_public_access public_access_cidrs = var.public_access_cidrs security_group_ids = var.eks_additional_security_group_ids + vpc_security_group_ids = var.vpc_security_group_ids } dynamic "encryption_config" { diff --git a/node_group/aws_managed/main.tf b/node_group/aws_managed/main.tf index 048d769..b07015c 100644 --- a/node_group/aws_managed/main.tf +++ b/node_group/aws_managed/main.tf @@ -38,18 +38,25 @@ resource "aws_launch_template" "this" { ram_disk_id = var.ram_disk_id default_version = var.update_launch_template_default_version ? var.launch_template_default_version : null - tag_specifications { - resource_type = "instance" - tags = var.launch_template_tags + + dynamic "tag_specifications" { + for_each = var.launch_template_tags != null ? [var.launch_template_tags] : [] + content { + resource_type = "instance" + tags = tag_specifications.value + } } - instance_market_options { - market_type = var.instance_market_options.market_type + # Dynamic block for instance_market_options + dynamic "instance_market_options" { + for_each = var.instance_market_options != null ? [var.instance_market_options] : [] + content {} - spot_options { - max_price = var.instance_market_options.spot_options.max_price + dynamic "spot_options" { + for_each = instance_market_options.value.spot_options != null ? [instance_market_options.value.spot_options] : [] + content {} + } } - } dynamic "block_device_mappings" { for_each = var.block_device_mappings diff --git a/node_group/fargate_profile/fargate.tf b/node_group/fargate_profile/fargate.tf index a1baa9c..b4db410 100644 --- a/node_group/fargate_profile/fargate.tf +++ b/node_group/fargate_profile/fargate.tf @@ -49,7 +49,7 @@ resource "aws_eks_fargate_profile" "default" { fargate_profile_name = format("%s-%s", module.labels.id, each.value.addon_name) pod_execution_role_arn = aws_iam_role.fargate_role[0].arn subnet_ids = var.subnet_ids - tags = module.labels.tags + tags = var.tags selector { namespace = lookup(each.value, "namespace", "default") diff --git a/node_group/fargate_profile/variables.tf b/node_group/fargate_profile/variables.tf index 225a55e..3b71b02 100644 --- a/node_group/fargate_profile/variables.tf +++ b/node_group/fargate_profile/variables.tf @@ -24,6 +24,12 @@ variable "attributes" { description = "Additional attributes (e.g. `1`)." } +variable "tags" { + type = map(any) + default = {} + description = "Additional tags (e.g. map(`BusinessUnit`,`XYZ`)." +} + variable "managedby" { type = string default = "hello@clouddorve.com" diff --git a/variables.tf b/variables.tf index ecaadae..1fbed8d 100644 --- a/variables.tf +++ b/variables.tf @@ -229,11 +229,11 @@ variable "endpoint_public_access" { description = "Indicates whether or not the Amazon EKS public API server endpoint is enabled. Default to AWS EKS resource and it is true." } -#variable "vpc_security_group_ids" { -# type = list(string) -# default = [] -# description = "A list of security group IDs to associate" -#} +variable "vpc_security_group_ids" { + type = list(string) + default = [] + description = "A list of security group IDs to associate" +} #-----------------------------------------------TimeOuts---------------------------------------------------------------- variable "cluster_timeouts" { @@ -320,12 +320,6 @@ variable "managed_node_group" { #-----------------------------------------------ASG-Schedule---------------------------------------------------------------- -#variable "create_schedule" { -# description = "Determines whether to create autoscaling group schedule or not" -# type = bool -# default = true -#} - variable "schedules" { description = "Map of autoscaling group schedule to create" type = map(any) From 1ed7b29f052122da949e1e56c308d664241cb4ee Mon Sep 17 00:00:00 2001 From: amanverma678 Date: Fri, 6 Dec 2024 01:56:14 +0530 Subject: [PATCH 42/48] fix: variables --- main.tf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/main.tf b/main.tf index 33c1421..dc96184 100644 --- a/main.tf +++ b/main.tf @@ -38,8 +38,7 @@ resource "aws_eks_cluster" "default" { endpoint_private_access = var.endpoint_private_access endpoint_public_access = var.endpoint_public_access public_access_cidrs = var.public_access_cidrs - security_group_ids = var.eks_additional_security_group_ids - vpc_security_group_ids = var.vpc_security_group_ids + security_group_ids = concat(var.eks_additional_security_group_ids, var.vpc_security_group_ids) } dynamic "encryption_config" { From ae92ee636cd97f1010b9b487bc24584f107ced6d Mon Sep 17 00:00:00 2001 From: amanverma678 Date: Fri, 6 Dec 2024 02:01:21 +0530 Subject: [PATCH 43/48] fix: variables --- node_group/aws_managed/main.tf | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/node_group/aws_managed/main.tf b/node_group/aws_managed/main.tf index b07015c..888f5ee 100644 --- a/node_group/aws_managed/main.tf +++ b/node_group/aws_managed/main.tf @@ -52,11 +52,13 @@ resource "aws_launch_template" "this" { for_each = var.instance_market_options != null ? [var.instance_market_options] : [] content {} - dynamic "spot_options" { - for_each = instance_market_options.value.spot_options != null ? [instance_market_options.value.spot_options] : [] - content {} + dynamic "spot_options" { + for_each = instance_market_options.value.spot_options != null ? [instance_market_options.value.spot_options] : [] + content { + max_price = spot_options.value.max_price + } } - } + } dynamic "block_device_mappings" { for_each = var.block_device_mappings From 2ea03f5fe9d831122500bfd2fd722e51dae344f3 Mon Sep 17 00:00:00 2001 From: amanverma678 Date: Fri, 6 Dec 2024 02:18:35 +0530 Subject: [PATCH 44/48] fix: variables --- node_group/aws_managed/main.tf | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/node_group/aws_managed/main.tf b/node_group/aws_managed/main.tf index 888f5ee..f2c2384 100644 --- a/node_group/aws_managed/main.tf +++ b/node_group/aws_managed/main.tf @@ -49,17 +49,20 @@ resource "aws_launch_template" "this" { # Dynamic block for instance_market_options dynamic "instance_market_options" { - for_each = var.instance_market_options != null ? [var.instance_market_options] : [] - content {} + for_each = var.instance_market_options != null ? [var.instance_market_options] : [] + content { + market_type = instance_market_options.value.market_type + } - dynamic "spot_options" { - for_each = instance_market_options.value.spot_options != null ? [instance_market_options.value.spot_options] : [] - content { - max_price = spot_options.value.max_price - } + # Dynamic block for spot_options within instance_market_options + dynamic "spot_options" { + for_each = instance_market_options.value.spot_options != null ? [instance_market_options.value.spot_options] : [] + content { + max_price = spot_options.value.max_price } + } } - + dynamic "block_device_mappings" { for_each = var.block_device_mappings content { From 4b75bc9d5e10e85d0f651971bbc1817a846d09c2 Mon Sep 17 00:00:00 2001 From: amanverma678 Date: Fri, 6 Dec 2024 03:06:21 +0530 Subject: [PATCH 45/48] fix: variables --- node_group/aws_managed/main.tf | 16 +++++----------- node_group/fargate_profile/fargate.tf | 2 +- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/node_group/aws_managed/main.tf b/node_group/aws_managed/main.tf index f2c2384..c9f375e 100644 --- a/node_group/aws_managed/main.tf +++ b/node_group/aws_managed/main.tf @@ -47,22 +47,16 @@ resource "aws_launch_template" "this" { } } - # Dynamic block for instance_market_options dynamic "instance_market_options" { - for_each = var.instance_market_options != null ? [var.instance_market_options] : [] - content { - market_type = instance_market_options.value.market_type - } + for_each = var.instance_market_options != null ? [var.instance_market_options] : [] + content { + market_type = instance_market_options.value.market_type - # Dynamic block for spot_options within instance_market_options - dynamic "spot_options" { - for_each = instance_market_options.value.spot_options != null ? [instance_market_options.value.spot_options] : [] - content { - max_price = spot_options.value.max_price + spot_options { + max_price = lookup(instance_market_options.value.spot_options, "max_price", null) } } } - dynamic "block_device_mappings" { for_each = var.block_device_mappings content { diff --git a/node_group/fargate_profile/fargate.tf b/node_group/fargate_profile/fargate.tf index b4db410..c36449f 100644 --- a/node_group/fargate_profile/fargate.tf +++ b/node_group/fargate_profile/fargate.tf @@ -49,7 +49,7 @@ resource "aws_eks_fargate_profile" "default" { fargate_profile_name = format("%s-%s", module.labels.id, each.value.addon_name) pod_execution_role_arn = aws_iam_role.fargate_role[0].arn subnet_ids = var.subnet_ids - tags = var.tags + tags = var.tags selector { namespace = lookup(each.value, "namespace", "default") From 1043664991eb9e43a45bbdc8012073d358c922ec Mon Sep 17 00:00:00 2001 From: amanverma678 Date: Sat, 7 Dec 2024 01:39:39 +0530 Subject: [PATCH 46/48] FIx:Unsupported attributes --- examples/aws_managed/example.tf | 6 +++--- node_group/aws_managed/main.tf | 37 ++++++++++++++++----------------- node_group/self_managed/main.tf | 2 +- variables.tf | 10 +++++++++ 4 files changed, 32 insertions(+), 23 deletions(-) diff --git a/examples/aws_managed/example.tf b/examples/aws_managed/example.tf index 3c4a940..0d3fbb1 100644 --- a/examples/aws_managed/example.tf +++ b/examples/aws_managed/example.tf @@ -325,9 +325,9 @@ module "eks" { critical = { name = "${module.eks.cluster_name}-critical" capacity_type = "ON_DEMAND" - min_size = 1 - max_size = 2 - desired_size = 2 + min_size = 0 + max_size = 1 + desired_size = 0 instance_types = ["t3.medium"] } diff --git a/node_group/aws_managed/main.tf b/node_group/aws_managed/main.tf index c9f375e..48c9cfc 100644 --- a/node_group/aws_managed/main.tf +++ b/node_group/aws_managed/main.tf @@ -22,22 +22,18 @@ module "labels" { resource "aws_launch_template" "this" { - count = var.enabled ? 1 : 0 - name = module.labels.id - description = var.launch_template_description - - ebs_optimized = var.ebs_optimized - image_id = var.ami_id - # # Set on node group instead - # instance_type = var.launch_template_instance_type - key_name = var.key_name - user_data = var.before_cluster_joining_userdata - vpc_security_group_ids = var.vpc_security_group_ids - disable_api_termination = var.disable_api_termination - kernel_id = var.kernel_id - ram_disk_id = var.ram_disk_id - default_version = var.update_launch_template_default_version ? var.launch_template_default_version : null - + count = var.enabled ? 1 : 0 + name = module.labels.id + description = var.launch_template_description + ebs_optimized = var.ebs_optimized + image_id = var.ami_id + key_name = var.key_name + user_data = var.before_cluster_joining_userdata + vpc_security_group_ids = var.vpc_security_group_ids + disable_api_termination = var.disable_api_termination + kernel_id = var.kernel_id + ram_disk_id = var.ram_disk_id + default_version = var.update_launch_template_default_version ? var.launch_template_default_version : null dynamic "tag_specifications" { for_each = var.launch_template_tags != null ? [var.launch_template_tags] : [] @@ -48,12 +44,15 @@ resource "aws_launch_template" "this" { } dynamic "instance_market_options" { - for_each = var.instance_market_options != null ? [var.instance_market_options] : [] + for_each = var.instance_market_options == true ? [{ market_type = "spot", spot_options = { max_price = "0.05" } }] : [] content { market_type = instance_market_options.value.market_type - spot_options { - max_price = lookup(instance_market_options.value.spot_options, "max_price", null) + dynamic "spot_options" { + for_each = (instance_market_options.value.spot_options != null) ? [instance_market_options.value.spot_options] : [] + content { + max_price = spot_options.value.max_price + } } } } diff --git a/node_group/self_managed/main.tf b/node_group/self_managed/main.tf index bd664a7..455bfb4 100644 --- a/node_group/self_managed/main.tf +++ b/node_group/self_managed/main.tf @@ -383,7 +383,7 @@ resource "aws_autoscaling_group" "this" { for_each = merge(local.self_managed_node_group_default_tags, var.tags) content { key = tag.key - value = tag.value + value = "" propagate_at_launch = true } } diff --git a/variables.tf b/variables.tf index 1fbed8d..2cb8da0 100644 --- a/variables.tf +++ b/variables.tf @@ -140,6 +140,16 @@ variable "outpost_config" { default = {} } +variable "instance_market_options" { + type = object({ + market_type = string + spot_options = optional(object({ + max_price = string + })) + }) + default = null +} + #-----------------------------------------------------------KMS--------------------------------------------------------- variable "cluster_encryption_config_enabled" { type = bool From 18410bc14092c75fad4ca0b5355b63bcc59d0c11 Mon Sep 17 00:00:00 2001 From: amanverma678 Date: Sat, 7 Dec 2024 01:43:50 +0530 Subject: [PATCH 47/48] FIx: format --- node_group/aws_managed/main.tf | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/node_group/aws_managed/main.tf b/node_group/aws_managed/main.tf index 48c9cfc..f86c62d 100644 --- a/node_group/aws_managed/main.tf +++ b/node_group/aws_managed/main.tf @@ -22,18 +22,18 @@ module "labels" { resource "aws_launch_template" "this" { - count = var.enabled ? 1 : 0 - name = module.labels.id - description = var.launch_template_description - ebs_optimized = var.ebs_optimized - image_id = var.ami_id - key_name = var.key_name - user_data = var.before_cluster_joining_userdata - vpc_security_group_ids = var.vpc_security_group_ids - disable_api_termination = var.disable_api_termination - kernel_id = var.kernel_id - ram_disk_id = var.ram_disk_id - default_version = var.update_launch_template_default_version ? var.launch_template_default_version : null + count = var.enabled ? 1 : 0 + name = module.labels.id + description = var.launch_template_description + ebs_optimized = var.ebs_optimized + image_id = var.ami_id + key_name = var.key_name + user_data = var.before_cluster_joining_userdata + vpc_security_group_ids = var.vpc_security_group_ids + disable_api_termination = var.disable_api_termination + kernel_id = var.kernel_id + ram_disk_id = var.ram_disk_id + default_version = var.update_launch_template_default_version ? var.launch_template_default_version : null dynamic "tag_specifications" { for_each = var.launch_template_tags != null ? [var.launch_template_tags] : [] From ec8fa51b1858052bc106274355b28e297abfab44 Mon Sep 17 00:00:00 2001 From: amanverma678 Date: Sat, 7 Dec 2024 02:41:59 +0530 Subject: [PATCH 48/48] FIx: format --- variables.tf | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/variables.tf b/variables.tf index 2cb8da0..1fbed8d 100644 --- a/variables.tf +++ b/variables.tf @@ -140,16 +140,6 @@ variable "outpost_config" { default = {} } -variable "instance_market_options" { - type = object({ - market_type = string - spot_options = optional(object({ - max_price = string - })) - }) - default = null -} - #-----------------------------------------------------------KMS--------------------------------------------------------- variable "cluster_encryption_config_enabled" { type = bool