Open AndrewCi opened 1 month ago
Thanks for raising this issue. Seems I updated it successfully. Below is my reproduce steps. Maybe there is no enough permission on the region/the service principal you are using. Please try below tf config to see if the issue still exists.
First apply:
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-postgresql-test03"
location = "eastus"
}
resource "azurerm_virtual_network" "test" {
name = "acctest-vn-test03"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
address_space = ["10.0.0.0/16"]
}
resource "azurerm_subnet" "test" {
name = "acctest-sn-test03"
resource_group_name = azurerm_resource_group.test.name
virtual_network_name = azurerm_virtual_network.test.name
address_prefixes = ["10.0.2.0/24"]
service_endpoints = ["Microsoft.Storage"]
delegation {
name = "fs"
service_delegation {
name = "Microsoft.DBforPostgreSQL/flexibleServers"
actions = [
"Microsoft.Network/virtualNetworks/subnets/join/action",
]
}
}
}
resource "azurerm_private_dns_zone" "test" {
name = "acctest03.postgres.database.azure.com"
resource_group_name = azurerm_resource_group.test.name
}
resource "azurerm_private_dns_zone_virtual_network_link" "test" {
name = "acctestVnetZonetest03.com"
private_dns_zone_name = azurerm_private_dns_zone.test.name
virtual_network_id = azurerm_virtual_network.test.id
resource_group_name = azurerm_resource_group.test.name
depends_on = [azurerm_subnet.test]
}
resource "azurerm_postgresql_flexible_server" "test" {
name = "psql-backup-test03-flexible-server"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
delegated_subnet_id = azurerm_subnet.test.id
private_dns_zone_id = azurerm_private_dns_zone.test.id
public_network_access_enabled = false
version = "16"
zone = "2"
administrator_login = "adminTerraform"
administrator_password = "QAZwsx123"
sku_name = "B_Standard_B1ms"
storage_mb = 32768
auto_grow_enabled = true
backup_retention_days = 7
geo_redundant_backup_enabled = false
depends_on = [azurerm_private_dns_zone_virtual_network_link.test]
}
Second apply:
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-postgresql-test03"
location = "eastus"
}
resource "azurerm_virtual_network" "test" {
name = "acctest-vn-test03"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
address_space = ["10.0.0.0/16"]
}
resource "azurerm_subnet" "test" {
name = "acctest-sn-test03"
resource_group_name = azurerm_resource_group.test.name
virtual_network_name = azurerm_virtual_network.test.name
address_prefixes = ["10.0.2.0/24"]
service_endpoints = ["Microsoft.Storage"]
delegation {
name = "fs"
service_delegation {
name = "Microsoft.DBforPostgreSQL/flexibleServers"
actions = [
"Microsoft.Network/virtualNetworks/subnets/join/action",
]
}
}
}
resource "azurerm_private_dns_zone" "test" {
name = "acctest03.postgres.database.azure.com"
resource_group_name = azurerm_resource_group.test.name
}
resource "azurerm_private_dns_zone_virtual_network_link" "test" {
name = "acctestVnetZonetest03.com"
private_dns_zone_name = azurerm_private_dns_zone.test.name
virtual_network_id = azurerm_virtual_network.test.id
resource_group_name = azurerm_resource_group.test.name
depends_on = [azurerm_subnet.test]
}
resource "azurerm_postgresql_flexible_server" "test" {
name = "psql-backup-test03-flexible-server"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
delegated_subnet_id = azurerm_subnet.test.id
private_dns_zone_id = azurerm_private_dns_zone.test.id
public_network_access_enabled = false
version = "16"
zone = "2"
administrator_login = "adminTerraform"
administrator_password = "QAZwsx123"
sku_name = "GP_Standard_D2ds_v4"
storage_mb = 32768
auto_grow_enabled = true
high_availability {
mode = "ZoneRedundant"
standby_availability_zone = 1
}
backup_retention_days = 7
geo_redundant_backup_enabled = false
depends_on = [azurerm_private_dns_zone_virtual_network_link.test]
}
Thank you for attempting to reproduce. Can it be related to storage tier? That's the only difference I could see with your provided TF files. Would you be able to retry with storage tier defined?
Is there an existing issue for this?
Community Note
Terraform Version
1.9.6
AzureRM Provider Version
4.4.0
Affected Resource(s)/Data Source(s)
azurerm_postgresql_flexible_server
Terraform Configuration Files
Terraform Config File First Apply
Terraform Config File Second Apply that causes the error
Debug Output/Panic Output
Expected Behaviour
Expected behavior would be that Terraform would know to update the VM SKU of PSQL Flexi Server first and then update the HA configuration
Actual Behaviour
Terraform attempted to update the HA first which failed because the prior SKU was burstable
Steps to Reproduce
TF apply when going from B_Standard_B1ms without HA to GP_Standard_D2ds_v4 with HA
Important Factoids
No response
References
No response