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

Support for PostgreSQL Flexible Server #8654

Closed
dhirschfeld opened this issue Sep 28, 2020 · 13 comments · Fixed by #11081
Closed

Support for PostgreSQL Flexible Server #8654

dhirschfeld opened this issue Sep 28, 2020 · 13 comments · Fixed by #11081

Comments

@dhirschfeld
Copy link
Contributor

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

Microsoft have just released a new type of PostgreSQL deployment called Flexible Server

New or Affected Resource(s)

I assume it would be a deployment option on azurerm_postgresql_server

References

@dhirschfeld

This comment has been minimized.

@dhirschfeld dhirschfeld changed the title Support for PostreSQL Flexible Server Support for PostgreSQL Flexible Server Sep 28, 2020
@tamland

This comment has been minimized.

@evertonmc
Copy link
Contributor

evertonmc commented Oct 26, 2020

I assume it would be a deployment option on azurerm_postgresql_server

I don't think so. The API is pretty different.
https://github.com/Azure/azure-sdk-for-go/tree/master/services/preview/postgresql/mgmt/2020-02-14-preview/postgresqlflexibleservers

@jcorioland

This comment has been minimized.

@fuesec

This comment has been minimized.

@fra-ga
Copy link

fra-ga commented Feb 24, 2021

Until this is implemented, maybe this will help others. I got it up and running with local exec. Here some code to get you started.
It creates the minimum database in westeurope and adds firewall rules for a web app created in another part of the code.
The commands are documented here. Adjust to your needs.

resource "null_resource" "database" {
  triggers = {
    RESOURCE_GROUP_NAME = azurerm_resource_group.rg.name
    DATABASE_NAME       = local.database_name
    ADMIN_PASSWORD      = random_password.rnd_database_secret.result
    ADMIN_USER          = local.database_user
    SKU_NAME            = "Standard_B1ms"
    TIER                = "Burstable"
  }
  provisioner "local-exec" {
    when    = create
    command = "az postgres flexible-server create --storage-size 32 --public-access none --sku-name ${self.triggers.SKU_NAME} --tier ${self.triggers.TIER} --version 12 --name ${self.triggers.DATABASE_NAME} --admin-password ${self.triggers.ADMIN_PASSWORD} --admin-user ${self.triggers.ADMIN_USER} --location westeurope --resource-group ${self.triggers.RESOURCE_GROUP_NAME}"
  }
  provisioner "local-exec" {
    when    = destroy
    command = "az postgres flexible-server delete --resource-group ${self.triggers.RESOURCE_GROUP_NAME} --name ${self.triggers.DATABASE_NAME} --yes"
  }
}

resource "null_resource" "database_firewall" {
  count = 10
  triggers = {
    RESOURCE_GROUP_NAME = azurerm_resource_group.rg.name
    DATABASE_NAME       = local.database_name
    APP_ACCESS_NAME     = local.webapp_name_backend
    IP                  = (split(",", azurerm_app_service.as_webapp_backend.possible_outbound_ip_addresses))[count.index]
  }
  provisioner "local-exec" {
    when    = create
    command = "az postgres flexible-server firewall-rule create --resource-group ${self.triggers.RESOURCE_GROUP_NAME} --name ${self.triggers.DATABASE_NAME} --rule-name ${self.triggers.APP_ACCESS_NAME}-${count.index} --start-ip-address ${self.triggers.IP} --end-ip-address ${self.triggers.IP}"
  }
  depends_on = [null_resource.database, ]
}

@nigel-decosta-rft
Copy link

Is there any update yet on when Postres Flexible Server will be supported? I can use the null_resource approach above but it is less than ideal.

Thanks

@ghost
Copy link

ghost commented Apr 30, 2021

This has been released in version 2.57.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.57.0"
}
# ... other configuration ...

@LukaszSzalek-TomTom
Copy link

hi
I would like to use azurerm_postgresql_database to create db on azurerm_postgresql_flexible_server.
but is seems that the call goes to Server instead of FlexibleServer.
Error:
Error: postgresql.DatabasesClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: Code="ResourceNotFound" Message="The Resource 'Microsoft.DBForPostgreSQL/servers/fakeDB' under resource group 'myRG' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"

Code
resource "azurerm_postgresql_database" "coresup_cpp" {
depends_on = [azurerm_postgresql_flexible_server.fakeDB]
name = "cpp"
resource_group_name = var.RESOURCE_GROUP_NAME
server_name = data.azurerm_postgresql_flexible_server.fakeDB.name
charset = "UTF8"
collation = "English_United States.1252"
}

provider 2.57
TF v0.15.1

Thanks

Lukasz

@BenWyattMilliman
Copy link

Flexible Server is actually a separate resource type, azurerm_postgresql_flexible_server. You can view the documentation here: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/postgresql_flexible_server

@marcoboffi
Copy link

So will a new resource be add in a near future to create db on azurerm_postgresql_flexible_server ?

@kzw
Copy link

kzw commented May 19, 2021

How about _configuration and _firewall_rule for postgres flexible? I tried to use existing resources with flexible server and not working.

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.