Skip to content

fix: Add full subnet group name when prefix is enabled #359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from

Conversation

david92rl
Copy link

Description

Currently, it's not possible to specify a prefix for the subnet group because coalesce(var.db_subnet_group_name, module.db_subnet_group.db_subnet_group_id, var.identifier) will return a simple name even if db_subnet_group_use_name_prefix is set to true.
This makes sure we always use the right sunet group id.

Breaking Changes

This is backwards compatible

How Has This Been Tested?

  • I have tested and validated these changes using one or more of the provided examples/* projects

Used the examples/complete-postgres example to make sure the db created uses the right subnet group id

@@ -1,6 +1,6 @@
locals {
master_password = var.create_db_instance && var.create_random_password ? random_password.master_password[0].result : var.password
db_subnet_group_name = !var.cross_region_replica && var.replicate_source_db != null ? null : coalesce(var.db_subnet_group_name, module.db_subnet_group.db_subnet_group_id, var.identifier)
db_subnet_group_name = ! var.cross_region_replica && var.replicate_source_db != null ? null : var.create_db_subnet_group ? module.db_subnet_group.db_subnet_group_id : coalesce(var.db_subnet_group_name, var.identifier)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can actually be more succinctly fixed with:

Suggested change
db_subnet_group_name = ! var.cross_region_replica && var.replicate_source_db != null ? null : var.create_db_subnet_group ? module.db_subnet_group.db_subnet_group_id : coalesce(var.db_subnet_group_name, var.identifier)
db_subnet_group_name = !var.cross_region_replica && var.replicate_source_db != null ? null : try(module.db_subnet_group.db_subnet_group_id, var.db_subnet_group_name)

what this does is:

  1. Try to get the computed subnet group ID, if that fails
  2. Use the var.db_subnet_group_name

I can't see a scenario where we don't can get past both the created or provided subnet group names so we can drop the var.identifier here

@elovelan
Copy link

elovelan commented Jan 11, 2022

@david92rl, any chance you're still looking at this? I'm running into this bug as well. While this is a one-line fix based on the code review, I'm also happy to open a PR against your master branch with the fix, or open a new PR closing this one. Please let me know!

elovelan added a commit to ZSuiteTech/terraform-aws-rds that referenced this pull request Jan 11, 2022
elovelan added a commit to ZSuiteTech/terraform-aws-rds that referenced this pull request Jan 11, 2022
elovelan added a commit to ZSuiteTech/terraform-aws-rds that referenced this pull request Jan 11, 2022
@elovelan
Copy link

@david92rl, I'm going to give this a go 😃

@antonbabenko
Copy link
Member

This issue has been resolved in version 4.0.0 🎉

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants