Skip to content

Commit 4af4f5c

Browse files
committed
feat: Update parameter group configuration and move from sub-module to root module
1 parent ff87e20 commit 4af4f5c

File tree

11 files changed

+52
-154
lines changed

11 files changed

+52
-154
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ Examples codified under the [`examples`](https://github.com/clowdhaus/terraform-
4141

4242
| Name | Source | Version |
4343
|------|--------|---------|
44-
| <a name="module_parameter_group"></a> [parameter\_group](#module\_parameter\_group) | ./modules/parameter_group | n/a |
4544
| <a name="module_subnet_group"></a> [subnet\_group](#module\_subnet\_group) | ./modules/subnet_group | n/a |
4645

4746
## Resources
4847

4948
| Name | Type |
5049
|------|------|
5150
| [aws_elasticache_cluster.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_cluster) | resource |
51+
| [aws_elasticache_parameter_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_parameter_group) | resource |
5252
| [aws_elasticache_replication_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_replication_group) | resource |
5353

5454
## Inputs
@@ -87,9 +87,9 @@ Examples codified under the [`examples`](https://github.com/clowdhaus/terraform-
8787
| <a name="input_num_cache_nodes"></a> [num\_cache\_nodes](#input\_num\_cache\_nodes) | The initial number of cache nodes that the cache cluster will have. For Redis, this value must be 1. For Memcached, this value must be between 1 and 40. If this number is reduced on subsequent runs, the highest numbered nodes will be removed | `number` | `1` | no |
8888
| <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 |
8989
| <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 |
90-
| <a name="input_parameter_group_description"></a> [parameter\_group\_description](#input\_parameter\_group\_description) | Description for the ElastiCache parameter group | `string` | `""` | no |
90+
| <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 |
9191
| <a name="input_parameter_group_family"></a> [parameter\_group\_family](#input\_parameter\_group\_family) | The family of the ElastiCache parameter group | `string` | `null` | no |
92-
| <a name="input_parameter_group_name"></a> [parameter\_group\_name](#input\_parameter\_group\_name) | The name of the parameter group to associate with this cache cluster | `string` | `null` | no |
92+
| <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 |
9393
| <a name="input_parameters"></a> [parameters](#input\_parameters) | List of ElastiCache parameters to apply | `list(map(string))` | `[]` | no |
9494
| <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 |
9595
| <a name="input_preferred_availability_zones"></a> [preferred\_availability\_zones](#input\_preferred\_availability\_zones) | List of the Availability Zones in which cache nodes are created | `list(string)` | `[]` | no |
@@ -119,8 +119,8 @@ Examples codified under the [`examples`](https://github.com/clowdhaus/terraform-
119119
| <a name="output_cluster_cache_nodes"></a> [cluster\_cache\_nodes](#output\_cluster\_cache\_nodes) | List of node objects including `id`, `address`, `port` and `availability_zone` |
120120
| <a name="output_cluster_configuration_endpoint"></a> [cluster\_configuration\_endpoint](#output\_cluster\_configuration\_endpoint) | (Memcached only) Configuration endpoint to allow host discovery |
121121
| <a name="output_cluster_engine_version_actual"></a> [cluster\_engine\_version\_actual](#output\_cluster\_engine\_version\_actual) | Because ElastiCache pulls the latest minor or patch for a version, this attribute returns the running version of the cache engine |
122-
| <a name="output_parameter_group_id"></a> [parameter\_group\_id](#output\_parameter\_group\_id) | The ElastiCache parameter group id |
123-
| <a name="output_parameter_group_name"></a> [parameter\_group\_name](#output\_parameter\_group\_name) | The ElastiCache parameter group name |
122+
| <a name="output_parameter_group_arn"></a> [parameter\_group\_arn](#output\_parameter\_group\_arn) | The AWS ARN associated with the parameter group |
123+
| <a name="output_parameter_group_id"></a> [parameter\_group\_id](#output\_parameter\_group\_id) | The ElastiCache parameter group name |
124124
| <a name="output_rep_group_arn"></a> [rep\_group\_arn](#output\_rep\_group\_arn) | ARN of the created ElastiCache Replication Group |
125125
| <a name="output_rep_group_coniguration_endpoint_address"></a> [rep\_group\_coniguration\_endpoint\_address](#output\_rep\_group\_coniguration\_endpoint\_address) | Address of the replication group configuration endpoint when cluster mode is enabled |
126126
| <a name="output_rep_group_engine_version_actual"></a> [rep\_group\_engine\_version\_actual](#output\_rep\_group\_engine\_version\_actual) | Because ElastiCache pulls the latest minor or patch for a version, this attribute returns the running version of the cache engine |
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-

main.tf

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,34 @@ resource "aws_elasticache_replication_group" "this" {
118118
tags = var.tags
119119
}
120120

121+
################################################################################
122+
# Parameter Group
123+
################################################################################
124+
125+
resource "aws_elasticache_parameter_group" "this" {
126+
count = var.create && var.create_parameter_group ? 1 : 0
127+
128+
description = coalesce(var.parameter_group_description, "ElastiCache parameter group")
129+
family = var.parameter_group_family
130+
name = var.parameter_group_name
131+
132+
dynamic "parameter" {
133+
for_each = var.parameters
134+
135+
content {
136+
name = parameter.value.name
137+
value = parameter.value.value
138+
}
139+
}
140+
141+
lifecycle {
142+
create_before_destroy = true
143+
}
144+
145+
tags = var.tags
146+
}
147+
148+
121149
################################################################################
122150
# Subnet Group
123151
################################################################################
@@ -137,14 +165,3 @@ module "subnet_group" {
137165
description = var.subnet_group_description
138166
subnet_ids = var.subnet_ids
139167
}
140-
141-
module "parameter_group" {
142-
source = "./modules/parameter_group"
143-
144-
create = var.create_parameter_group
145-
identifier = local.identifier
146-
name = var.parameter_group_name
147-
family = var.parameter_group_family
148-
description = var.parameter_group_description
149-
parameters = var.parameters
150-
}

modules/parameter_group/README.md

Lines changed: 0 additions & 42 deletions
This file was deleted.

modules/parameter_group/main.tf

Lines changed: 0 additions & 23 deletions
This file was deleted.

modules/parameter_group/outputs.tf

Whitespace-only changes.

modules/parameter_group/variables.tf

Lines changed: 0 additions & 41 deletions
This file was deleted.

modules/parameter_group/versions.tf

Lines changed: 0 additions & 10 deletions
This file was deleted.

outputs.tf

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
################################################################################
32
# Cluster
43
################################################################################
@@ -84,12 +83,12 @@ output "subnet_group_ids" {
8483
# Parameter Group
8584
################################################################################
8685

87-
output "parameter_group_name" {
88-
description = "The ElastiCache parameter group name"
89-
value = module.parameter_group.name
86+
output "parameter_group_arn" {
87+
description = "The AWS ARN associated with the parameter group"
88+
value = try(aws_elasticache_parameter_group.this[0].arn, null)
9089
}
9190

9291
output "parameter_group_id" {
93-
description = "The ElastiCache parameter group id"
94-
value = module.parameter_group.id
92+
description = "The ElastiCache parameter group name"
93+
value = try(aws_elasticache_parameter_group.this[0].id, null)
9594
}

0 commit comments

Comments
 (0)