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

Unable to create postgres_extension in Azure #460

Closed
eddykaya opened this issue Aug 1, 2024 · 2 comments
Closed

Unable to create postgres_extension in Azure #460

eddykaya opened this issue Aug 1, 2024 · 2 comments

Comments

@eddykaya
Copy link

eddykaya commented Aug 1, 2024

Hi there,

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

Terraform Version

1.8.4

Affected Resource(s)

Please list the resources as a list, for example:

  • postgresql_extension

Terraform Configuration Files

resource "postgresql_extension" "my_extension" {
  for_each = var.postgres_extensions

  name = each.key

  depends_on = [
    azurerm_postgresql_flexible_server_configuration.postgres_extension_config
  ]
}

provider "postgresql" {
  alias           = "default"
  host            = azurerm_private_endpoint.postgres_private_endpoint.private_service_connection[0].private_ip_address
  port            = 5432
  database        = var.postgres_db_name
  username        = var.postgres_admin_login
  password        = var.postgres_admin_password
  superuser       = false
  sslmode         = "require"
  connect_timeout = 15
}

terraform {
  required_providers {
    postgresql = {
      source  = "cyrilgdn/postgresql"
      version = "1.22.0"
    }
  }
}

Debug Output

I don't know which part of the DEBUG output is relevant, there is a lot of sensitive information, please specify which part of the debug output you need.

Expected Behavior

The postgres extension gets created

Actual Behavior

THe postgres extension could not be created as the provider tries to connect to 127.0.0.1 instead of the ip address set in the provider settings. This is definetly the correct IP as I am able to create schemas and roles:

│ Error: Error connecting to PostgreSQL server  (scheme: postgres): XXXXdXXXXial tcp 127.0.0.1:5432: connect: connection refused
│ 
│   with module.azure_resources.module.tsa-postgres-db.postgresql_extension.my_extension["uuid-ossp"],
│   on ../../../modules/postgres-db/main.tf line 148, in resource "postgresql_extension" "my_extension":
│  148: resource "postgresql_extension" "my_extension" {
│ 

Steps to Reproduce

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

  1. terraform apply

Important Factoids

Using azure postgres flexible server

References

@nejec
Copy link
Contributor

nejec commented Sep 3, 2024

Can you confirm the same provider works for other postgresql_* resources as well?

If not a secret, what is the output terraform state show azurerm_private_endpoint.postgres_private_endpoint.private_service_connection[0]?

We are using postgresql_extension without any problem as long the provider is configured ok.

@cyrilgdn
Copy link
Owner

Hi @eddykaya

I close this issue for now but feel free to reopen it and to answer @nejec question so we can help you.
Most probably azurerm_private_endpoint.postgres_private_endpoint.private_service_connection[0].private_ip_address is empty or not yet resolved so the host is set to the default value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants