cyrilgdn / terraform-provider-postgresql

Terraform PostgreSQL provider
https://www.terraform.io/docs/providers/postgresql/
Mozilla Public License 2.0
356 stars 182 forks source link

Unable to connect with Azure postgres with Terraform #288

Open nimblenitin opened 1 year ago

nimblenitin commented 1 year ago

Hi there,

Thank you for opening an issue. Please provide the following information:

Terraform Version

Run terraform -v to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed.

Terraform v1.3.6 on windows_386

Affected Resource(s)

Please list the resources as a list, for example:

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

resource "postgresql_role" "db_user" {
  for_each = var.create_databases_users ? toset(var.databases_names) : toset([])

  name        = lookup(var.user_name, each.value)
  login       = true
  password    = var.user_pass
  create_role = true
  roles       = []
  search_path = concat([each.value, "$user"], lookup(var.database_users_search_path, each.value, []))

  provider = postgresql.create_users

  depends_on = [azurerm_postgresql_flexible_server_database.postgresql_flexible_db]
}

provider "postgresql" {

  host      = var.postgresql_db_server_fqdn
  port      = 5432
  username  = var.administrator_login
  password  = var.administrator_password
  sslmode   = "require"
  superuser = false

  alias = "create_users"
}

Debug Output

Please provider a link to a GitHub Gist containing the complete debug output: https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the debug output in the issue; just paste a link to the Gist.

Panic Output

If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the crash.log.

Expected Behavior

What should have happened? Terraform should be able to connect with db

Actual Behavior

What actually happened? Error: error detecting capabilities: error PostgreSQL version: dial tcp XX.XXX.XXX.XXX:5432: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform plan

Important Factoids

Are there anything atypical about your accounts that we should know? For example: Running in EC2 Classic? Custom version of OpenStack? Tight ACLs?

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

jbg commented 1 year ago
Error: error detecting capabilities: error PostgreSQL version: dial tcp XX.XXX.XXX.XXX:5432: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

The error clearly indicates that connecting to the PostgreSQL server timed out. Are you able to connect with psql from the same system running Terraform? You probably have a routing or network security groups misconfiguration.