hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.61k stars 4.65k forks source link

AZ PostgreSQL Flexible Server - Static Server Parameter (shared_preload_libraries) Recognizes as update-in-place #21356

Closed cg-mls closed 5 months ago

cg-mls commented 1 year ago

Is there an existing issue for this?

Community Note

Terraform Version

1.3.7

AzureRM Provider Version

3.44.1

Affected Resource(s)/Data Source(s)

azurerm_postgresql_flexible_server_configuration

Terraform Configuration Files

variable "shared_preload_libraries" {
  type        = list(string)
  description = "Must be a string, which is why used with join function"
  default = [
    "wal2json",
    "pg_cron",
    "pg_stat_statements"
  ]
}

resource "azurerm_postgresql_flexible_server_configuration" "shared_preload_libraries" {
  name      = "shared_preload_libraries"
  server_id = azurerm_postgresql_flexible_server.postgres_flexible.id
  value     = join(",", var.shared_preload_libraries)
}

Note: I have given a plain string for the value instead of using a variable, it still didn't make a difference, and wanted to make an update in place.

Debug Output/Panic Output

~ value     = "pg_cron,pg_stat_statements,wal2json" -> "pg_cron,wal2json,pg_stat_statements"

Expected Behaviour

No changes required.

Actual Behaviour

Terraform will perform update-in-place

Steps to Reproduce

Run tf apply and create shared_preload_libraries server configuration. After apply is completed successfully, run another tf apply. You will see that tf will recognize it as a change, and run another apply. That causes server to restart after every single apply even if there are no actual changes. We could use lifecycle ignore changes temporarily, however that is not a long term solution.

Important Factoids

N/A

References

I believe there was this pr https://github.com/hashicorp/terraform-provider-azurerm/pull/20044 got merged in for static parameters to cause restart on the server. Might be the root cause of the issue.

neil-yechenwei commented 1 year ago

Thanks for raising this issue. Service team confirmed that restarting server against static parameters is expected behavior. Here the problem is that the value content returned by GET API is sorted alphabetically.

neil-yechenwei commented 1 year ago

Thanks for raising this issue. I assume you have to set the value alphabetically. See more details from here.

cg-mls commented 1 year ago

Thank you, will try to list em alphabetically

rcskosir commented 5 months ago

Thank you for taking the time to raise this! I am going to close this with @neil-yechenwei‘s response as an answer. If you have future questions, I suggest using the Community Resources, such as the Azure Provider forum.

github-actions[bot] commented 4 months ago

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.