Skip to content

Commit 3cb8496

Browse files
committed
fix: Correct default naming scheme for parameter group to allow users full control
1 parent cc408cb commit 3cb8496

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ No modules.
9393
| <a name="input_num_node_groups"></a> [num\_node\_groups](#input\_num\_node\_groups) | Number of node groups (shards) for this Redis replication group. Changing this number will trigger a resizing operation before other settings modifications | `number` | `null` | no |
9494
| <a name="input_outpost_mode"></a> [outpost\_mode](#input\_outpost\_mode) | Specify the outpost mode that will apply to the cache cluster creation. Valid values are `single-outpost` and `cross-outpost`, however AWS currently only supports `single-outpost` mode | `string` | `null` | no |
9595
| <a name="input_parameter_group_description"></a> [parameter\_group\_description](#input\_parameter\_group\_description) | The description of the ElastiCache parameter group. Defaults to `Managed by Terraform` | `string` | `null` | no |
96-
| <a name="input_parameter_group_family"></a> [parameter\_group\_family](#input\_parameter\_group\_family) | The family of the ElastiCache parameter group | `string` | `null` | no |
96+
| <a name="input_parameter_group_family"></a> [parameter\_group\_family](#input\_parameter\_group\_family) | The family of the ElastiCache parameter group | `string` | `""` | no |
9797
| <a name="input_parameter_group_name"></a> [parameter\_group\_name](#input\_parameter\_group\_name) | The name of the parameter group. If `create_parameter_group` is `true`, this is the name assigned to the parameter group created. Otherwise, this is the name of an existing parameter group | `string` | `null` | no |
9898
| <a name="input_parameters"></a> [parameters](#input\_parameters) | List of ElastiCache parameters to apply | `list(map(string))` | `[]` | no |
9999
| <a name="input_port"></a> [port](#input\_port) | The port number on which each of the cache nodes will accept connections. For Memcached the default is `11211`, and for Redis the default port is `6379` | `number` | `null` | no |

main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ resource "aws_elasticache_replication_group" "this" {
126126
################################################################################
127127

128128
locals {
129-
parameter_group_name = try(coalesce(var.parameter_group_name, var.cluster_id, var.replication_group_id), "")
129+
inter_parameter_group_name = "${try(coalesce(var.cluster_id, var.replication_group_id), "")}-${var.parameter_group_family}"
130+
parameter_group_name = coalesce(var.parameter_group_name, local.inter_parameter_group_name)
130131

131132
parameter_group_name_result = var.create && var.create_parameter_group ? aws_elasticache_parameter_group.this[0].id : var.parameter_group_name
132133
}
@@ -136,7 +137,7 @@ resource "aws_elasticache_parameter_group" "this" {
136137

137138
description = coalesce(var.parameter_group_description, "ElastiCache parameter group")
138139
family = var.parameter_group_family
139-
name = "${local.parameter_group_name}-${var.parameter_group_family}"
140+
name = local.parameter_group_name
140141

141142
dynamic "parameter" {
142143
for_each = var.parameters

variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ variable "parameter_group_description" {
295295
variable "parameter_group_family" {
296296
description = "The family of the ElastiCache parameter group"
297297
type = string
298-
default = null
298+
default = ""
299299
}
300300

301301
variable "parameter_group_name" {

0 commit comments

Comments
 (0)