Skip to content

Commit

Permalink
RDS parameter groups now create_before_destroy
Browse files Browse the repository at this point in the history
This requires a change in name for each (using `name_prefix`), which
will likely recreate all parameter groups.  This is intended to work
around an issue where AWS won't allow the parameter group to be
recreated while RDS are using it.

See these issues for reference:

* hashicorp/terraform-provider-aws#6448
* hashicorp/terraform-provider-aws#6049
* hashicorp/terraform-provider-aws#2402
* hashicorp/terraform-provider-aws#1571
* hashicorp/terraform-provider-aws#526
  • Loading branch information
tammersaleh committed Feb 21, 2020
1 parent a4a0e56 commit aaf8e92
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ci/terraform/rds_module/parameter_group.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resource "aws_db_parameter_group" "parameter_group_postgres" {
count = "${var.rds_db_engine == "postgres" ? 1 : 0}"
name = "${var.rds_parameter_group_name != "" ?
name_prefix = "${var.rds_parameter_group_name != "" ?
var.rds_parameter_group_name :
"${replace("${var.stack_description}-${var.rds_db_name}", "/[^a-zA-Z-]+/", "-")}"}"
family = "${var.rds_parameter_group_family}"
Expand Down Expand Up @@ -30,11 +30,15 @@ resource "aws_db_parameter_group" "parameter_group_postgres" {
value = "${var.rds_force_ssl}"
apply_method = "pending-reboot"
}

lifecycle {
create_before_destroy = true
}
}

resource "aws_db_parameter_group" "parameter_group_mysql" {
count = "${var.rds_db_engine == "mysql" ? 1 : 0}"
name = "${var.rds_parameter_group_name != "" ?
name_prefix = "${var.rds_parameter_group_name != "" ?
var.rds_parameter_group_name :
"${replace("${var.stack_description}-${var.rds_db_name}", "/[^a-zA-Z-]+/", "-")}"}"
family = "${var.rds_parameter_group_family}"
Expand All @@ -46,4 +50,8 @@ resource "aws_db_parameter_group" "parameter_group_mysql" {
name = "log_output"
value = "FILE"
}

lifecycle {
create_before_destroy = true
}
}

0 comments on commit aaf8e92

Please sign in to comment.