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’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

Merged
merged 3 commits into from
Aug 10, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
locals {
role_arn = var.create_proxy && var.create_iam_role ? aws_iam_role.this[0].arn : var.role_arn
role_name = coalesce(var.iam_role_name, var.name)
policy_name = coalesce(var.iam_policy_name, var.name)
role_arn = var.create_proxy && var.create_iam_role ? aws_iam_role.this[0].arn : var.role_arn
role_name = coalesce(var.iam_role_name, var.name)
policy_name = coalesce(var.iam_policy_name, var.name)
db_proxy_endpoints = var.create_proxy ? var.db_proxy_endpoints : {}
}

data "aws_region" "current" {}
Expand Down Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
for_each = local.db_proxy_endpoints
for_each = {for k,v in var.db_proxy_endpoints: k => v if var.create_proxy }

Copy link
Contributor Author

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...

Copy link
Contributor Author

@fatmcgav-depop fatmcgav-depop Aug 10, 2022

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)


db_proxy_name = aws_db_proxy.this[0].name
db_proxy_endpoint_name = each.value.name
Expand Down