Skip to content

Commit

Permalink
Small fixes - convert param values to string, set auto failover to tr…
Browse files Browse the repository at this point in the history
…ue if cluster enabled (#141)

* added description on resources aws_elasticache_subnet_group and aws_elasticache_parameter_group

* Convert param values to strings

* Set auto failover to true if cluster mode enabled

* make github/init

Co-authored-by: Simone Ferraro <simone.ferraro@onsimo.it>
  • Loading branch information
nitrocode and simoferr98 authored Dec 14, 2021
1 parent 7293a0e commit 73ba085
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/auto-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ template: |
replacers:
# Remove irrelevant information from Renovate bot
- search: '/(?<=---\s+)+^#.*(Renovate configuration|Configuration)(?:.|\n)*?This PR has been generated .*/gm'
- search: '/(?<=---\s)\s*^#.*(Renovate configuration|Configuration)(?:.|\n)*?This PR has been generated .*/gm'
replace: ''
# Remove Renovate bot banner image
- search: '/\[!\[[^\]]*Renovate\][^\]]*\](\([^)]*\))?\s*\n+/gm'
Expand Down
18 changes: 10 additions & 8 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,23 @@ locals {
}

resource "aws_elasticache_subnet_group" "default" {
count = module.this.enabled && var.elasticache_subnet_group_name == "" && length(var.subnets) > 0 ? 1 : 0
name = module.this.id
subnet_ids = var.subnets
count = module.this.enabled && var.elasticache_subnet_group_name == "" && length(var.subnets) > 0 ? 1 : 0
name = module.this.id
description = "Elasticache subnet group for ${module.this.id}"
subnet_ids = var.subnets
}

resource "aws_elasticache_parameter_group" "default" {
count = module.this.enabled ? 1 : 0
name = module.this.id
family = var.family
count = module.this.enabled ? 1 : 0
name = module.this.id
description = "Elasticache parameter group for ${module.this.id}"
family = var.family

dynamic "parameter" {
for_each = var.cluster_mode_enabled ? concat([{ name = "cluster-enabled", value = "yes" }], var.parameter) : var.parameter
content {
name = parameter.value.name
value = parameter.value.value
value = tostring(parameter.value.value)
}
}
}
Expand All @@ -112,7 +114,7 @@ resource "aws_elasticache_replication_group" "default" {
port = var.port
parameter_group_name = join("", aws_elasticache_parameter_group.default.*.name)
availability_zones = length(var.availability_zones) == 0 ? null : [for n in range(0, var.cluster_size) : element(var.availability_zones, n)]
automatic_failover_enabled = var.automatic_failover_enabled
automatic_failover_enabled = var.cluster_mode_enabled ? true : var.automatic_failover_enabled
multi_az_enabled = var.multi_az_enabled
subnet_group_name = local.elasticache_subnet_group_name
# It would be nice to remove null or duplicate security group IDs, if there are any, using `compact`,
Expand Down

0 comments on commit 73ba085

Please sign in to comment.