Skip to content

Commit 7089c71

Browse files
authored
fix: Remove trailing hyphen from cluster security group and iam role name prefix (#1745)
1 parent b2f6b19 commit 7089c71

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,7 @@ Full contributing [guidelines are covered here](https://github.com/terraform-aws
730730
| <a name="input_node_security_group_tags"></a> [node\_security\_group\_tags](#input\_node\_security\_group\_tags) | A map of additional tags to add to the node security group created | `map(string)` | `{}` | no |
731731
| <a name="input_node_security_group_use_name_prefix"></a> [node\_security\_group\_use\_name\_prefix](#input\_node\_security\_group\_use\_name\_prefix) | Determines whether node security group name (`node_security_group_name`) is used as a prefix | `string` | `true` | no |
732732
| <a name="input_openid_connect_audiences"></a> [openid\_connect\_audiences](#input\_openid\_connect\_audiences) | List of OpenID Connect audience client IDs to add to the IRSA provider | `list(string)` | `[]` | no |
733+
| <a name="input_prefix_separator"></a> [prefix\_separator](#input\_prefix\_separator) | The separator to use between the prefix and the generated timestamp for resource names | `string` | `"-"` | no |
733734
| <a name="input_self_managed_node_group_defaults"></a> [self\_managed\_node\_group\_defaults](#input\_self\_managed\_node\_group\_defaults) | Map of self-managed node group default configurations | `any` | `{}` | no |
734735
| <a name="input_self_managed_node_groups"></a> [self\_managed\_node\_groups](#input\_self\_managed\_node\_groups) | Map of self-managed node group definitions to create | `any` | `{}` | no |
735736
| <a name="input_subnet_ids"></a> [subnet\_ids](#input\_subnet\_ids) | A list of subnet IDs where the EKS cluster (ENIs) will be provisioned along with the nodes/node groups. Node groups can be deployed within a different set of subnet IDs from within the node group configuration | `list(string)` | `[]` | no |

UPGRADE-18.0.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Please consult the `examples` directory for reference example configurations. If
2828
- The underlying autoscaling group and launch template have been updated to more closely match that of the [`terraform-aws-autoscaling`](https://github.com/terraform-aws-modules/terraform-aws-autoscaling) module and the features it offers
2929
- The previous iteration used a count over a list of node group definitions which was prone to disruptive updates; this is now replaced with a map/for_each to align with that of the EKS managed node group and Fargate profile behaviors/style
3030
- The user data configuration supported across the module has been completely revamped. A new `_user_data` internal sub-module has been created to consolidate all user data configuration in one location which provides better support for testability (via the [`examples/user_data`](https://github.com/terraform-aws-modules/terraform-aws-eks/tree/master/examples/user_data) example). The new sub-module supports nearly all possible combinations including the ability to allow users to provide their own user data template which will be rendered by the module. See the `examples/user_data` example project for the full plethora of example configuration possibilities and more details on the logic of the design can be found in the [`modules/_user_data`](https://github.com/terraform-aws-modules/terraform-aws-eks/tree/master/modules/_user_data_) directory.
31+
- Resource name changes may cause issues with existing resources. For example, security groups and IAM roles cannot be renamed, they must be recreated. Recreation of these resources may also trigger a recreation of the cluster. To use the legacy (< 18.x) resource naming convention, set `prefix_separator` to "".
3132

3233
## Additional changes
3334

@@ -166,6 +167,7 @@ Please consult the `examples` directory for reference example configurations. If
166167
- `cluster_addons`
167168
- `cluster_identity_providers`
168169
- `fargate_profile_defaults`
170+
- `prefix_separator` added to support legacy behavior of not having a prefix separator
169171
- EKS Managed Node Group sub-module (was `node_groups`)
170172
- `platform`
171173
- `enable_bootstrap_user_data`

main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ resource "aws_security_group" "cluster" {
107107
count = local.create_cluster_sg ? 1 : 0
108108

109109
name = var.cluster_security_group_use_name_prefix ? null : local.cluster_sg_name
110-
name_prefix = var.cluster_security_group_use_name_prefix ? "${local.cluster_sg_name}-" : null
110+
name_prefix = var.cluster_security_group_use_name_prefix ? "${local.cluster_sg_name}${var.prefix_separator}" : null
111111
description = var.cluster_security_group_description
112112
vpc_id = var.vpc_id
113113

@@ -191,7 +191,7 @@ resource "aws_iam_role" "this" {
191191
count = var.create && var.create_iam_role ? 1 : 0
192192

193193
name = var.iam_role_use_name_prefix ? null : local.iam_role_name
194-
name_prefix = var.iam_role_use_name_prefix ? "${local.iam_role_name}-" : null
194+
name_prefix = var.iam_role_use_name_prefix ? "${local.iam_role_name}${var.prefix_separator}" : null
195195
path = var.iam_role_path
196196
description = var.iam_role_description
197197

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ variable "tags" {
1010
default = {}
1111
}
1212

13+
variable "prefix_separator" {
14+
description = "The separator to use between the prefix and the generated timestamp for resource names"
15+
type = string
16+
default = "-"
17+
}
18+
1319
################################################################################
1420
# Cluster
1521
################################################################################

0 commit comments

Comments
 (0)