From 21fefa5a95e47d7ea749a10006d300b2a2771c9d Mon Sep 17 00:00:00 2001 From: Yichun Ma Date: Wed, 31 May 2023 23:01:30 +0800 Subject: [PATCH 1/2] `azurerm_postgresql_flexible_server` - fix issue updating `storage_mb` and `backup_retention_days` together --- .../postgres/postgresql_flexible_server_resource.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/services/postgres/postgresql_flexible_server_resource.go b/internal/services/postgres/postgresql_flexible_server_resource.go index 5947bcb77090..c1286acd1b4e 100644 --- a/internal/services/postgres/postgresql_flexible_server_resource.go +++ b/internal/services/postgres/postgresql_flexible_server_resource.go @@ -710,7 +710,15 @@ func resourcePostgresqlFlexibleServerUpdate(d *pluginsdk.ResourceData, meta inte } if d.HasChange("storage_mb") { - parameters.Properties.Storage = expandArmServerStorage(d) + storageUpdateParameters := servers.ServerForUpdate{ + Properties: &servers.ServerPropertiesForUpdate{ + Storage: expandArmServerStorage(d), + }, + } + + if err := client.UpdateThenPoll(ctx, *id, storageUpdateParameters); err != nil { + return fmt.Errorf("updating `storage_mb` for %s: %+v", *id, err) + } } if d.HasChange("backup_retention_days") { From fb1040ec049e6e09d90e8d0fb6595ada2d00a970 Mon Sep 17 00:00:00 2001 From: Yichun Ma Date: Thu, 1 Jun 2023 15:50:48 +0800 Subject: [PATCH 2/2] add comment for spec issue --- .../services/postgres/postgresql_flexible_server_resource.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/services/postgres/postgresql_flexible_server_resource.go b/internal/services/postgres/postgresql_flexible_server_resource.go index c1286acd1b4e..e16350f926e1 100644 --- a/internal/services/postgres/postgresql_flexible_server_resource.go +++ b/internal/services/postgres/postgresql_flexible_server_resource.go @@ -710,6 +710,7 @@ func resourcePostgresqlFlexibleServerUpdate(d *pluginsdk.ResourceData, meta inte } if d.HasChange("storage_mb") { + // TODO remove the additional update after https://github.com/Azure/azure-rest-api-specs/issues/22867 is fixed storageUpdateParameters := servers.ServerForUpdate{ Properties: &servers.ServerPropertiesForUpdate{ Storage: expandArmServerStorage(d),