Skip to content

Commit 1630a4b

Browse files
bryantbiggsspr-mweber3
authored andcommitted
fix: Add conditional variable to allow users to opt out of tagging cluster primary security group (terraform-aws-modules#2034)
1 parent 4d7e590 commit 1630a4b

File tree

7 files changed

+12
-7
lines changed

7 files changed

+12
-7
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.64.1
3+
rev: v1.68.1
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_validate

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ We are grateful to the community for contributing bugfixes and improvements! Ple
296296
| <a name="input_create"></a> [create](#input\_create) | Controls if EKS resources should be created (affects nearly all resources) | `bool` | `true` | no |
297297
| <a name="input_create_aws_auth_configmap"></a> [create\_aws\_auth\_configmap](#input\_create\_aws\_auth\_configmap) | Determines whether to create the aws-auth configmap. NOTE - this is only intended for scenarios where the configmap does not exist (i.e. - when using only self-managed node groups). Most users should use `manage_aws_auth_configmap` | `bool` | `false` | no |
298298
| <a name="input_create_cloudwatch_log_group"></a> [create\_cloudwatch\_log\_group](#input\_create\_cloudwatch\_log\_group) | Determines whether a log group is created by this module for the cluster logs. If not, AWS will automatically create one if logging is enabled | `bool` | `true` | no |
299+
| <a name="input_create_cluster_primary_security_group_tags"></a> [create\_cluster\_primary\_security\_group\_tags](#input\_create\_cluster\_primary\_security\_group\_tags) | Indicates whether or not to tag the cluster's primary security group. This security group is created by the EKS service, not the module, and therefore tagging is handled after cluster creation | `bool` | `true` | no |
299300
| <a name="input_create_cluster_security_group"></a> [create\_cluster\_security\_group](#input\_create\_cluster\_security\_group) | Determines if a security group is created for the cluster or use the existing `cluster_security_group_id` | `bool` | `true` | no |
300301
| <a name="input_create_cni_ipv6_iam_policy"></a> [create\_cni\_ipv6\_iam\_policy](#input\_create\_cni\_ipv6\_iam\_policy) | Determines whether to create an [`AmazonEKS_CNI_IPv6_Policy`](https://docs.aws.amazon.com/eks/latest/userguide/cni-iam-role.html#cni-iam-role-create-ipv6-policy) | `bool` | `false` | no |
301302
| <a name="input_create_iam_role"></a> [create\_iam\_role](#input\_create\_iam\_role) | Determines whether a an IAM role is created or to use an existing IAM role | `bool` | `true` | no |

examples/complete/main.tf

-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ module "eks" {
125125
# EKS Managed Node Group(s)
126126
eks_managed_node_group_defaults = {
127127
ami_type = "AL2_x86_64"
128-
disk_size = 50
129128
instance_types = ["m6i.large", "m5.large", "m5n.large", "m5zn.large"]
130129

131130
attach_cluster_primary_security_group = true

examples/eks_managed_node_group/main.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ module "eks" {
114114

115115
eks_managed_node_group_defaults = {
116116
ami_type = "AL2_x86_64"
117-
disk_size = 50
118117
instance_types = ["m6i.large", "m5.large", "m5n.large", "m5zn.large"]
119118

120119
# We are using the IRSA created below for permissions
@@ -133,6 +132,8 @@ module "eks" {
133132
create_launch_template = false
134133
launch_template_name = ""
135134

135+
disk_size = 50
136+
136137
# Remote access cannot be specified with a launch template
137138
remote_access = {
138139
ec2_ssh_key = aws_key_pair.this.key_name
@@ -254,7 +255,6 @@ module "eks" {
254255
EOT
255256

256257
capacity_type = "SPOT"
257-
disk_size = 256
258258
force_update_version = true
259259
instance_types = ["m6i.large", "m5.large", "m5n.large", "m5zn.large"]
260260
labels = {

examples/self_managed_node_group/main.tf

+1-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ module "eks" {
9696
}
9797

9898
self_managed_node_group_defaults = {
99-
disk_size = 50
99+
create_security_group = false
100100
}
101101

102102
self_managed_node_groups = {
@@ -216,7 +216,6 @@ module "eks" {
216216
echo "you are free little kubelet!"
217217
EOT
218218

219-
disk_size = 256
220219
instance_type = "m6i.large"
221220

222221
launch_template_name = "self-managed-ex"

main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ resource "aws_ec2_tag" "cluster_primary_security_group" {
6363
# This should not affect the name of the cluster primary security group
6464
# Ref: https://github.com/terraform-aws-modules/terraform-aws-eks/pull/2006
6565
# Ref: https://github.com/terraform-aws-modules/terraform-aws-eks/pull/2008
66-
for_each = { for k, v in merge(var.tags, var.cluster_tags) : k => v if local.create && k != "Name" }
66+
for_each = { for k, v in merge(var.tags, var.cluster_tags) : k => v if local.create && k != "Name" && var.create_cluster_primary_security_group_tags }
6767

6868
resource_id = aws_eks_cluster.this[0].vpc_config[0].cluster_security_group_id
6969
key = each.key

variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ variable "cluster_tags" {
101101
default = {}
102102
}
103103

104+
variable "create_cluster_primary_security_group_tags" {
105+
description = "Indicates whether or not to tag the cluster's primary security group. This security group is created by the EKS service, not the module, and therefore tagging is handled after cluster creation"
106+
type = bool
107+
default = true
108+
}
109+
104110
variable "cluster_timeouts" {
105111
description = "Create, update, and delete timeout configurations for the cluster"
106112
type = map(string)

0 commit comments

Comments
 (0)