aws_db_parameter_group: set lifecycle.create_before_destroy = true #337
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This allows importing paramter groups, without failing with the following error message:
Error: Error deleting DB parameter group: InvalidDBParameterGroupState: One or more database instances are still members of this parameter group foo-postgres12-parameter-group, so the group cannot be deleted
status code: 400, request id: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Motivation and Context
I previously used
db_cluster_parameter_group_name
anddb_parameter_group_name
to point to some externally-created parameter group names.While trying to update the
engine_version
, it failed with some incompatibilities, so I wanted to switch to having the terraform module create them.I:
db_cluster_parameter_group_name
db_parameter_group_name
create_db_cluster_parameter_group = true
create_db_parameter_group = true
db_parameter_group_family = "aurora-postgresql12"
I moved the pre-existing parameter groups into the module state:
Terraform tried to delete the parameter groups first, before creating the new ones:
Setting
lifecycle.before_destroy
on thelifecycle.create_before_destroy = true
on theaws_db_parameter_group
seems to help. Terraform first creates the new DB parameter group, and then removes the old one.This has also been suggested in hashicorp/terraform-provider-aws#6448 (comment).
Breaking Changes
N/A
How Has This Been Tested?
examples/*
to demonstrate and validate my change(s)examples/*
projectspre-commit run -a
on my pull request