Problems with postgresql connect in Azure

519 views
Skip to first unread message

Gergely Tóth

unread,
Jan 31, 2018, 7:01:40 AM1/31/18
to Terraform
Hi all,
I would create a postgresql database in azure and after it I would connect with the postgresql provider

Here is how I create the database

resource "azurerm_postgresql_server" "qumulateserver" {
    name                = "${var.database_server_name}"
    location            = "${azurerm_resource_group.qumulateterraform.location}"  
    resource_group_name = "${azurerm_resource_group.qumulateterraform.name}"
   
sku {
    name = "PGSQLB50"
    capacity = 50
    tier = "Basic"
  }

  administrator_login = "admin"
  administrator_login_password = "password"
  version = "9.5"
  storage_mb = "51200"
  ssl_enforcement = "Enabled"
}

Here how I would connect

provider "postgresql" {
  alias = "pgconnect"
  host = "${var.database_server_name}${var.postgres_fqdn}"
  port = 5432
  database = "${var.database_name}"
  username = "${azurerm_postgresql_server.qumulateserver.administrator_login}@${var.database_server_name}${var.postgres_fqdn}"
  password = "${azurerm_postgresql_server.qumulateserver.administrator_login_password}"
  expected_version = "9.5.0"
}

So the probelm is with the versions. I get the following error
Error: Error refreshing state: 1 error(s) occurred:

* provider.postgresql.pgconnect: Error initializing PostgreSQL client: error detecting capabilities: error parsing version: Invalid character(s) found in patch number "9,"

I tried to change the db versions to the same minor and patchset versions but doesn't help. What can I do?




rose bk

unread,
Feb 6, 2018, 4:53:36 AM2/6/18
to Terraform

Clint Shryock

unread,
Feb 13, 2018, 1:49:30 PM2/13/18
to terrafo...@googlegroups.com
Hey Gergely -

The error is coming from the postgresql provider, it's connecting and calling `SELECT VERSION()`. For whatever reason, the version is coming back in a format that's not passing semver parsing. After some slicing of the string, it's ending up with literally "9," when I imagine it was expecting just "9". 

Is it possible for you to extract this number into a variable that both azurerm_postgresql_server.qumulateserver and the postgresql configuration use the same value? Either use a variable for them, or have azurerm_postgresql_server.qumulateserver feed into the postgresql provider:

provider "postgresql" {
  alias = "pgconnect"
  host = "${var.database_server_name}${var.postgres_fqdn}"
  port = 5432
  database = "${var.database_name}"
  username = "${azurerm_postgresql_server.qumulateserver.administrator_login}@${var.database_server_name}${var.postgres_fqdn}"
  password = "${azurerm_postgresql_server.qumulateserver.administrator_login_password}"
  expected_version = "${azurerm_postgresql_server.qumulateserver.version}"
}

Let me know if that helps!

Cheers,
Clint

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/94cf5852-30b2-47c9-9928-6f54a755f286%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Robson Peixoto

unread,
Jun 14, 2018, 6:57:03 PM6/14/18
to Terraform
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.

Robson Peixoto

unread,
Jun 14, 2018, 6:57:13 PM6/14/18
to Terraform
This PR https://github.com/terraform-providers/terraform-provider-postgresql/pull/40 will solve this problem.

On Tuesday, February 13, 2018 at 3:49:30 PM UTC-3, Clint Shryock wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages