terraform-provider-azurerm
terraform-provider-azurerm copied to clipboard
Support for Database Server Parameters
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
Currently Terraform doesn't appear to keep track of changes to the options within the server parameters blade. There are no examples of how to add this configuration under the documentation for azurerm_postgresql_flexible_server_configuration.
One of these possible server parameters is azure_extensions which supports up to 50 database extensions.
Azure server parameters shown in Azure portal:

After making changes to these server parmaters and saving in Azure portal, issuing commands terraform init and terraform plan results in the following message:
No changes. Your infrastructure matches the configuration. This is incorrect, because the state of the parameters was changed outside of terraform.
New or Affected Resource(s)
azurerm_<DATABASE>_flexible_server_configurationbut really this applies to any Azure DB.
Potential Terraform Configuration
resource "azurerm_postgresql_flexible_server" "this" {
name = "bar"
resource_group_name = azurerm_resource_group.this.name
location. = azurerm_resource_group.this.location
version = "13"
administrator_login = "..."
administrator_password = random_password.admin.result
backup_retention_days = 7
storage_mb = 32768
delegated_subnet_id = var.subnet_id
private_dns_zone_id = var.private_dns_zone_id
sku_name = "GP_Standard_D2ds_v4"
}
resource "azurerm_postgresql_flexible_server_configuration" "this" {
# optional server parameters
wal_level = "LOGICAL"
max_wal_size = 1024
azure_extensions = ['LTREE', 'CUBE', 'BTREE_GIST'....]
}
References
- #0000
@alicyn thank you for opening this issue. Could you try the tf config below to support database server parameters in Terraform?
resource "azurerm_postgresql_flexible_server_configuration" "test" {
name = "wal_level"
server_id = azurerm_postgresql_flexible_server.test.id
value = "LOGICAL"
}
resource "azurerm_postgresql_flexible_server_configuration" "test1" {
name = "max_wal_size"
server_id = azurerm_postgresql_flexible_server.test.id
value = "2048"
}
resource "azurerm_postgresql_flexible_server_configuration" "test2" {
name = "azure.extensions"
server_id = azurerm_postgresql_flexible_server.test.id
value = "CUBE,CITEXT,BTREE_GIST"
}
This worked great for me. I wish there was a better way to document this because I searched for quite sometime today to figure out how to enable postgis extensions through terraform. Thank you.
resource "azurerm_postgresql_flexible_server_configuration" "test2" {
name = "azure.extensions"
server_id = azurerm_postgresql_flexible_server.test.id
value = "CUBE,CITEXT,BTREE_GIST"
}
@sinbai sorry for the late reply...I was able to use this tf config to specify the server parameters. Terraform also correctly detects a diff in the state if a server parameter is changed in Azure portal outside of TF.
I agree however that there should be better official documentation on the supported config for azurerm_postgresql_flexible_server_configuration
@alicyn @bruschke thanks for your feedback. I have added an example on how to use Azure Extensions in Terraform document. Since PR https://github.com/hashicorp/terraform-provider-azurerm/pull/17580 adding example has been released in v3.14.0 of the Terraform Provider. Would you mind if we close this issue?
I'm closing this issue with noticing things have been unblocked and usage examples have been added by sinbai. Feel free to suggest to reactivate this issue if there are further questions.
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.