Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

The aws_db_subnet_group data block should allow tag lookups #25860

Open
jwyoungpm opened this issue Jul 18, 2022 · 1 comment
Open

The aws_db_subnet_group data block should allow tag lookups #25860

jwyoungpm opened this issue Jul 18, 2022 · 1 comment
Labels
enhancement Requests to existing resources that expand the functionality or scope. good first issue Call to action for new contributors looking for a place to start. Smaller or straightforward issues. service/rds Issues and PRs that pertain to the rds service.

Comments

@jwyoungpm
Copy link

jwyoungpm commented Jul 18, 2022

Community Note

  • Please vote on this issue by adding a 馃憤 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

The datablock for aws_db_subnet_group should support lookup by tag. If you create the group without a name, it gets a terraform generated ID which is not friendly, particularly in multi-region, multi-account envs.

This usually leads you to create a big if/else block enumerating all the subnet group names. Additionally, you can't move an RDS instance to another db subnet group in the same VPC - once you start using the group it's difficult to migrate.

If we could simply look the aws_db_subnet_group up using a filter similar to this data source we could pretty easily mitigate this issue by adding tags to the group (funny enough, the Name tag is likely what we'd use) then using a data block like:

data "aws_db_subnet_group" "my_group" {
  filter {
    name   = "tag:Name"
    values = ["yakdriver"]
  }
}

Name should also be added as an output attribute to the data source, it currently isn't. I assume that is because you don't need the lookup if you already know the name.

New or Affected Resource(s)

  • aws_db_subnet_group data block

Potential Terraform Configuration

data "aws_db_subnet_group" "my_group" {
  filter {
    name   = "tag:Name"
    values = ["yakdriver"]
  }
}

resource "aws_db_instance" "my_instance" {
     ...
     db_subnet_group_name = data.aws_db_subnet_group.my_group.name
     ...
}

References

  • #0000
@jwyoungpm jwyoungpm added the enhancement Requests to existing resources that expand the functionality or scope. label Jul 18, 2022
@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. service/rds Issues and PRs that pertain to the rds service. labels Jul 18, 2022
@justinretzolk justinretzolk added good first issue Call to action for new contributors looking for a place to start. Smaller or straightforward issues. and removed needs-triage Waiting for first response or review from a maintainer. labels Jul 21, 2022
@magreenbaum
Copy link

It looks like the upstream sdk doesn't support filters for DescribeDBSubnetGroups.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Requests to existing resources that expand the functionality or scope. good first issue Call to action for new contributors looking for a place to start. Smaller or straightforward issues. service/rds Issues and PRs that pertain to the rds service.
Projects
None yet
Development

No branches or pull requests

3 participants