-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
fix: Disable endpoint creation when setting create_proxy = false
#12
fix: Disable endpoint creation when setting create_proxy = false
#12
Conversation
Spotted this issue whilst trying to integrate this module into some existing code where we don't always want to create a RDS Proxy instance, but when we are creating a proxy we want a default set of endpoints. Setting `create_proxy = false` works for the majority of resources, however the `aws_db_proxy_endpoint` resource uses a `for_each` which will try and create endpoints against a non-existent DB proxy. So switch to using a `local` which gets set to an empty map if `var.create_proxy` is false.
create_proxy = false
create_proxy = false
create_proxy = false
create_proxy = false
main.tf
Outdated
@@ -68,7 +69,7 @@ resource "aws_db_proxy_target" "db_cluster" { | |||
} | |||
|
|||
resource "aws_db_proxy_endpoint" "this" { | |||
for_each = var.db_proxy_endpoints | |||
for_each = local.db_proxy_endpoints |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for_each = local.db_proxy_endpoints | |
for_each = {for k,v in var.db_proxy_endpoints: k => v if var.create_proxy } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did try this first, but I couldn't get it to work...
I'll try again though...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And for whatever reason it worked this time... Updated in 2a76143
(#12)
Instead add the conditional to the `for_each` statement. Thanks for the suggestion @bryantbiggs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you @fatmcgav-depop !
This PR is included in version 2.1.1 🎉 |
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. |
Spotted this issue whilst trying to integrate this module into some existing code where we don't always want to create a RDS Proxy instance, but when we are creating a proxy we want a default set of endpoints.
Setting
create_proxy = false
works for the majority of resources, however theaws_db_proxy_endpoint
resource uses afor_each
which will try and create endpoints against a non-existent DB proxy.So switch to using alocal
which gets set to an empty map ifvar.create_proxy
is false.In order to fix this, add a conditional to the
for_each
statement.Description
Motivation and Context
Breaking Changes
How Has This Been Tested?
examples/*
to demonstrate and validate my change(s)examples/*
projectspre-commit run -a
on my pull request