0

I'm deploying Azure Postgres Flexible Server with Terraform as described in GitHub. The configuration works as expected, no issues there. The only divination from that GitHub template is that I want to configure pgBouncer for Postgres which is now supported natively. I don't see a way how I can create this configuration (i.e., enable this feature).

I've done some research and discovered the configuration feature is not quite available (at least according to the open ticket in GitHub here). At the same time, one of the published replies suggests using azurerm_postgresql_flexible_server_configuration and this resource type is available in Terraform indeed. However, Microsoft documentation states that to enable and configure pgBouncer I need to introduce 7 parameters. I thought that to make the code tidier, I can use a list and foreach loop, like this:

locals {
  pg_config = {
    "pgbouncer.default_pool_size" : "50",
    "pgBouncer.max_client_conn"   : "5000",
    "pgBouncer.pool_mode"         : "TRANSACTION"
    etc...
  }
}

resource "azurerm_postgresql_flexible_server_configuration" "postgres_fs_config" {
  for_each = local.pg_config
  name = each.key
  value = each.value
  server_id = azurerm_postgresql_flexible_server.postgres-fs.id
}

Is this the best way to configure Postgres (without involving CDK)? Did I miss something?

1 Answer 1

1

Ok, I verified this approach and it works like a charm. Will stick to it for now.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.