From c2490c5148e11ee8ace3811cea1e61d42680a4b4 Mon Sep 17 00:00:00 2001 From: Anton Babenko Date: Fri, 3 Sep 2021 16:54:59 +0200 Subject: [PATCH] feat: Ability to tag just EKS cluster (#1569) --- README.md | 1 + cluster.tf | 5 ++++- variables.tf | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9107ca7436..693e017c13 100644 --- a/README.md +++ b/README.md @@ -239,6 +239,7 @@ Apache 2 Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraf | [cluster\_name](#input\_cluster\_name) | Name of the EKS cluster. Also used as a prefix in names of related resources. | `string` | n/a | yes | | [cluster\_security\_group\_id](#input\_cluster\_security\_group\_id) | If provided, the EKS cluster will be attached to this security group. If not given, a security group will be created with necessary ingress/egress to work with the workers | `string` | `""` | no | | [cluster\_service\_ipv4\_cidr](#input\_cluster\_service\_ipv4\_cidr) | service ipv4 cidr for the kubernetes cluster | `string` | `null` | no | +| [cluster\_tags](#input\_cluster\_tags) | A map of tags to add to just the eks resource. | `map(string)` | `{}` | no | | [cluster\_version](#input\_cluster\_version) | Kubernetes version to use for the EKS cluster. | `string` | n/a | yes | | [create\_eks](#input\_create\_eks) | Controls if EKS resources should be created (it affects almost all resources) | `bool` | `true` | no | | [create\_fargate\_pod\_execution\_role](#input\_create\_fargate\_pod\_execution\_role) | Controls if the EKS Fargate pod execution IAM role should be created. | `bool` | `true` | no | diff --git a/cluster.tf b/cluster.tf index 13d38a09a7..4e5086c853 100644 --- a/cluster.tf +++ b/cluster.tf @@ -12,7 +12,10 @@ resource "aws_eks_cluster" "this" { enabled_cluster_log_types = var.cluster_enabled_log_types role_arn = local.cluster_iam_role_arn version = var.cluster_version - tags = var.tags + tags = merge( + var.tags, + var.cluster_tags, + ) vpc_config { security_group_ids = compact([local.cluster_security_group_id]) diff --git a/variables.tf b/variables.tf index aca69a8d49..064243605f 100644 --- a/variables.tf +++ b/variables.tf @@ -98,6 +98,12 @@ variable "tags" { default = {} } +variable "cluster_tags" { + description = "A map of tags to add to just the eks resource." + type = map(string) + default = {} +} + variable "vpc_id" { description = "VPC where the cluster and workers will be deployed." type = string