-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Description
Is there an existing issue for this?
- I have searched the existing issues
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 comments along the lines of "+1", "me too" or "any updates", 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 and review the contribution guide to help.
Terraform Version
v1.13.3
AzureRM Provider Version
4.48.0
Affected Resource(s)/Data Source(s)
azurerm_postgresql_flexible_server
Terraform Configuration Files
# Data source that accesses the current configuration of the AzureRM provider.
data "azurerm_client_config" "current" {}
data "azurerm_private_dns_zone" "flex_server" {
name = var.private_dns_zone_domain_name
}
data "azurerm_resource_group" "network" {
name = var.pgsql_resource_group_name_for_delegated_subnet
}
data "azurerm_virtual_network" "vnet" {
resource_group_name = var.pgsql_resource_group_name_for_delegated_subnet
name = var.pgsql_virtual_network_name_for_delegated_subnet
}
data "azurerm_subnet" "pgsql" {
resource_group_name = var.pgsql_resource_group_name_for_delegated_subnet
virtual_network_name = var.pgsql_virtual_network_name_for_delegated_subnet
name = var.pgsql_subnet_name_for_delegated_subnet
}
resource "azurerm_resource_group" "primary" {
name = "rg-${local.resource_suffix}"
location = var.azure_location
tags = local.tags
}
resource "azurerm_management_lock" "primary_resource_group" {
count = var.create_resource_group_lock_for_primary ? 1 : 0
name = "lock-${azurerm_resource_group.primary.name}"
lock_level = "CanNotDelete"
scope = azurerm_resource_group.primary.id
notes = "'CanNotDelete' lock applied to '${azurerm_resource_group.primary.name}'."
}
module "postgresql_flexible_server" {
source = "./modules/postgresql_flexible_server"
for_each = var.pgsql_servers
resource_group_name = azurerm_resource_group.primary.name
azure_location = var.azure_location
alz_location = var.alz_location
workload_type = local.workload_type
environment = each.value.environment_override != null ? each.value.environment_override : var.environment
delegated_subnet_id = data.azurerm_subnet.pgsql.id
private_dns_zone_id = data.azurerm_private_dns_zone.flex_server.id
# kv_id = module.key_vault.id
pgsql_admin_login = each.value.administrator_login_username
pgsql_geo_redundant_backup_enabled = each.value.geo_redundant_backup_enabled
pgsql_high_availability = each.value.high_availability
pgsql_high_availability_mode = each.value.high_availability_mode # ZoneRedundant is not possible in West Europe & France Central at the time of writing (03/02/2023)
pgsql_backup_retention_days = each.value.backup_retention_days
pgsql_create_mode = each.value.create_mode
pgsql_public_network_access_enabled = each.value.public_network_access_enabled
pgsql_version = each.value.version
create_management_lock = false
active_directory_auth_enabled = each.value.active_directory_auth_enabled
tenant_id = data.azurerm_client_config.current.tenant_id
active_directory_administrators = each.value.active_directory_administrators
tags = local.tags
resource_name_suffix = each.key
pgsql_storage_mb = each.value.storage_mb
pgsql_sku_name = each.value.sku_name
pgsql_storage_auto_grow_enabled = can(each.value.storage_auto_grow_enabled) ? each.value.storage_auto_grow_enabled : false
}
# Variables
# Common variables
variable "subscription_id" {
type = string
description = "The Azure subscription ID."
}
variable "environment" {
type = string
description = "Environment that the infrastructure is part of. The environment must be one of: `nonprod`, `prod` or `all`."
validation {
condition = contains(["nonprod", "prod", "all"], var.environment)
error_message = "The environment must be one of: `nonprod`, `prod` or `all`."
}
}
variable "business_unit" {
type = string
description = "The team that requested the resources."
}
variable "project" {
type = string
description = "The contextual name of the project (e.g. useful-app)."
}
variable "azure_location" {
type = string
description = "The Azure geographical location where the resources are deployed."
}
variable "alz_location" {
type = string
description = "The custom name of location of the resources (eg. `we1`, `fc1`, etc)."
}
variable "custom_tags" {
type = map(string)
default = {}
description = "A list of tags to append to the resource."
}
/*********************************************
* Primary server instance
*********************************************/
variable "create_resource_group_lock_for_primary" {
type = bool
default = true
description = "If set to `true` a lock will be placed at resource group level. This affects the main resource group where the primary DB and resources will be placed."
}
variable "resource_group_lock_level_for_primary" {
description = "Resource group lock level to apply. Possible values: `CanNotDelete` or `ReadOnly`."
type = string
default = "CanNotDelete"
validation {
condition = contains(["CanNotDelete", "ReadOnly"], var.resource_group_lock_level_for_primary)
error_message = "The lock level must be one of: `CanNotDelete` or `ReadOnly`."
}
}
variable "pgsql_servers" {
type = map(object({
sku_name = string
storage_mb = string
active_directory_auth_enabled = optional(bool, true)
active_directory_administrators = optional(list(object({
object_id = string,
principal_name = string,
principal_type = string
})), [])
administrator_login_username = optional(string, "dbadmin")
storage_auto_grow_enabled = optional(bool)
environment_override = optional(string)
high_availability = optional(bool, false)
high_availability_mode = optional(string, "SameZone")
public_network_access_enabled = optional(bool, false)
version = optional(string, "13")
backup_retention_days = optional(number, 7)
geo_redundant_backup_enabled = optional(bool, false)
create_mode = optional(string, "Default")
create_replica = optional(bool, false)
replica_high_availability = optional(bool, false)
replica_high_availability_mode = optional(string, "SameZone")
}))
description = "PostgreSQL servers configuration"
}
variable "pgsql_resource_group_name_for_delegated_subnet" {
type = string
nullable = false
description = "The name of the resource group where the Virtual Network is located in."
}
variable "pgsql_virtual_network_name_for_delegated_subnet" {
type = string
nullable = false
description = "The name of the Virtual Network where the delegated subnet is located in."
}
variable "pgsql_subnet_name_for_delegated_subnet" {
type = string
nullable = false
description = "The name of the subnet delegated to `Microsoft.DBforPostgreSQL/flexibleServers`."
}
##########################
# Private DNS Zone
##########################
variable "private_dns_zone_domain_name" {
type = string
description = "DNS domain name (including `.postgres.database.azure.com`) for the PostgreSQL service."
}
# ##########################
# # KeyVault
# ##########################
# variable "cicd_identity_object_id" {
# type = string
# nullable = false
# description = "Object ID of the CI/CD identity that is used to deploy and create pgsql secret in KeyVault"
# }
# variable "keyvault_reader_object_ids" {
# type = list(string)
# default = ["73ba5a92-37cd-458f-a17f-d3784f4db77f"] // AZBNL-Apps-DBA (group)
# description = "Object IDs of the users and/or group that need read access to secrets in KeyVault"
# }
# variable "keyvault_writer_object_ids" {
# type = list(string)
# default = []
# description = "Object IDs of the users and/or group that need write access to secrets in KeyVault"
# }
# variable "purge_protection_enabled" {
# type = bool
# default = true
# description = "Is Purge Protection enabled for this Key Vault?"
# }
# ##########################
# # PostgreSQL
# ##########################
# variable "create_pgsql_management_lock" {
# type = bool
# default = true
# description = "If set to `true`, a lock will be applied to the PostgreSQL server."
# }
# variable "pgsql_delegated_network_rg_name" {
# type = string
# nullable = false
# description = "The name of the resource group where the network resources are located."
# }
# variable "pgsql_delegated_vnet_name" {
# type = string
# nullable = false
# description = "The name of the VNET where the subnet is located."
# }
# variable "pgsql_delegated_subnet_name" {
# type = string
# nullable = false
# description = "The name of the virtual network subnet to create the PostgreSQL Flexible Server."
# }
# variable "pgsql_admin_login" {
# type = string
# nullable = false
# description = "Administrator Login for the PostgreSQL Flexible Server."
# }
# variable "pgsql_servers" {
# type = map(object({
# sku_name = string
# storage_mb = string
# active_directory_auth_enabled = optional(bool, true)
# active_directory_administrators = optional(list(object({
# object_id = string,
# principal_name = string,
# principal_type = string
# })), [])
# storage_auto_grow_enabled = optional(bool)
# environment_override = optional(string)
# high_availability = optional(bool, false)
# high_availability_mode = optional(string, "SameZone")
# public_network_access_enabled = optional(bool, false)
# version = optional(string, "13")
# backup_retention_days = optional(number, 7)
# geo_redundant_backup_enabled = optional(bool, false)
# create_mode = optional(string, "Default")
# create_replica = optional(bool, false)
# replica_high_availability = optional(bool, false)
# replica_high_availability_mode = optional(string, "SameZone")
# }))
# description = "PostgreSQL servers configuration"
# }
# ##########################
# # Replica PostgreSQL
# ##########################
# variable "create_rg_replica_lock" {
# type = bool
# default = true
# description = "If set to `true` a lock will be placed at resource group level. This affects the main resource group where the replica DB and resources will be placed."
# }
# variable "create_pgsql_replica_management_lock" {
# type = bool
# default = true
# description = "If set to `true`, a lock will be applied to the PostgreSQL server."
# }
# variable "replica_azure_location" {
# type = string
# nullable = true
# default = ""
# description = "The Azure geographical location where the resources are deployed."
# }
# variable "replica_alz_location" {
# type = string
# nullable = true
# default = ""
# description = "The Allianz name of location of the resources (eg. `we1`, `fc1`, etc)."
# }
# variable "replica_pgsql_delegated_network_rg_name" {
# type = string
# nullable = true
# default = ""
# description = "The name of the resource group where the network resources are located."
# }
# variable "replica_pgsql_delegated_vnet_name" {
# type = string
# nullable = true
# default = ""
# description = "The name of the VNET where the subnet is located."
# }
# variable "replica_pgsql_delegated_subnet_name" {
# type = string
# nullable = true
# default = ""
# description = "The name of the virtual network subnet to create the PostgreSQL Flexible Server."
# }
# #
# # Log analytics workspace
# #
# variable "log_analytics_workspace_resource_group" {
# type = string
# description = "The name of the resource group where the log analytics workspace is located."
# }
# variable "log_analytics_workspace_name" {
# type = string
# description = "The name of the log analytics workspace."
# }
# #
# # Diagnostic settings
# #
# variable "diagnostic_setting_name" {
# description = "The name of this diagnostic setting."
# type = string
# default = "audit-logs"
# }
# variable "diagnostic_setting_enabled_log_category_groups" {
# type = set(string)
# default = ["audit", "allLogs"]
# description = "A list of log categories to be enabled for this diagnostic setting."
# }
# variable "diagnostic_setting_enabled_metric_categories" {
# type = list(string)
# default = ["AllMetrics"]
# description = "A list of metric categories to be enabled for this diagnostic setting."
# }
Debug Output/Panic Output
2025-10-15T19:13:52.324+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: [DEBUG] GET https://management.azure.com/subscriptions//resourceGroups/rg-bnl-we1-nonprod-service-deploy-shared-pgsql-sccplus/providers/Microsoft.DBforPostgreSQL/flexibleServers/pgsql-company-we1-nonprod-service-labs-sccplus-001?api-version=2024-08-01
2025-10-15T19:13:53.200+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: [DEBUG] AzureRM Response for https://management.azure.com/subscriptions//resourceGroups/rg-bnl-we1-nonprod-service-deploy-shared-pgsql-sccplus/providers/Microsoft.DBforPostgreSQL/flexibleServers/pgsql-company-we1-nonprod-service-labs-sccplus-001?api-version=2024-08-01:
2025-10-15T19:13:53.200+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: HTTP/2.0 404 Not Found
2025-10-15T19:13:53.200+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: Content-Length: 316
2025-10-15T19:13:53.200+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: Cache-Control: no-cache
2025-10-15T19:13:53.200+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: Content-Type: application/json; charset=utf-8
2025-10-15T19:13:53.200+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: Date: Wed, 15 Oct 2025 17:13:52 GMT
2025-10-15T19:13:53.200+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: Expires: -1
2025-10-15T19:13:53.200+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: Pragma: no-cache
2025-10-15T19:13:53.200+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: Strict-Transport-Security: max-age=31536000; includeSubDomains
2025-10-15T19:13:53.200+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: X-Cache: CONFIG_NOCACHE
2025-10-15T19:13:53.200+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: X-Content-Type-Options: nosniff
2025-10-15T19:13:53.200+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: X-Ms-Correlation-Request-Id: ae53c7ed-0a0a-4294-9853-0286397e7d44
2025-10-15T19:13:53.200+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: X-Ms-Failure-Cause: gateway
2025-10-15T19:13:53.200+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: X-Ms-Request-Id: ae53c7ed-0a0a-4294-9853-0286397e7d44
2025-10-15T19:13:53.200+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: X-Ms-Routing-Request-Id: WESTEUROPE:20251015T171353Z:ae53c7ed-0a0a-4294-9853-0286397e7d44
2025-10-15T19:13:53.200+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: X-Msedge-Ref: Ref A: AB9548FF03334C898E0B573CD70F52B8 Ref B: CH1AA2020603049 Ref C: 2025-10-15T17:13:53Z
2025-10-15T19:13:53.200+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5
2025-10-15T19:13:53.200+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: {"error":{"code":"ResourceNotFound","message":"The Resource 'Microsoft.DBforPostgreSQL/flexibleServers/pgsql-company-we1-nonprod-service-labs-sccplus-001' under resource group 'rg-bnl-we1-nonprod-service-deploy-shared-pgsql-sccplus' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"}}
2025-10-15T19:13:53.200+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: [DEBUG]: Default 'storage_tier' Set -> "P4"
2025-10-15T19:13:53.202+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: [DEBUG] AzureRM Request:
2025-10-15T19:13:53.202+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: PUT /subscriptions/some-id/resourceGroups/rg-bnl-we1-nonprod-service-deploy-shared-pgsql-sccplus/providers/Microsoft.DBforPostgreSQL/flexibleServers/pgsql-company-we1-nonprod-service-labs-sccplus-001?api-version=2024-08-01 HTTP/1.1
2025-10-15T19:13:53.202+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: Host: management.azure.com
2025-10-15T19:13:53.202+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: User-Agent: HashiCorp/go-azure-sdk (Go-http-Client/1.1 servers/2024-08-01) HashiCorp Terraform/1.13.3 (+https://www.terraform.io) terraform-provider-azurerm/dev pid-222c6c49-1b0a-5959-a213-6608f9eb8820
2025-10-15T19:13:53.202+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: Content-Length: 1291
2025-10-15T19:13:53.202+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: Content-Type: application/json; charset=utf-8
2025-10-15T19:13:53.202+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: Accept-Encoding: gzip
2025-10-15T19:13:53.202+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5
2025-10-15T19:13:53.202+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: {"identity":{"type":"None","userAssignedIdentities":null},"location":"westeurope","properties":{"administratorLogin":"dbadmin","administratorLoginPassword":"f3NWwCNaQUZCU4sBjhU9G74m5fbn06uW","authConfig":{"activeDirectoryAuth":"Enabled","passwordAuth":"Enabled","tenantId":"6e06e42d-6925-47c6-b9e7-9581c7ca302a"},"backup":{"geoRedundantBackup":"Disabled"},"createMode":"Update","highAvailability":{"mode":"Disabled"},"network":{"delegatedSubnetResourceId":"/subscriptions/some-id/resourceGroups/rg-d-we1-company-default-primary-networking/providers/Microsoft.Network/virtualNetworks/vnet-d-we1-company-default-primary/subnets/sub-d-we1-enterprise-44-81-46-192-28","privateDnsZoneArmResourceId":"/subscriptions/some-id/resourceGroups/rg-bnl-global-nonprod-shared-resources/providers/Microsoft.Network/privateDnsZones/flex.nonprod.postgres.database.azure.com","publicNetworkAccess":"Disabled"},"storage":{"autoGrow":"Disabled","storageSizeGB":32,"tier":"P4"},"version":"16"},"sku":{"name":"Standard_B2s","tier":"Burstable"},"tags":{"alz_location":"we1","app.service":"AS_Postgress_SQL_Cloud_Database_BNL_T","business_unit":"labs","created_with":"terraform","deployment_mode":"automation","environment":"nonprod","workload_type":"service"}}
2025-10-15T19:13:53.202+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: [DEBUG] PUT https://management.azure.com/subscriptions//resourceGroups/rg-bnl-we1-nonprod-service-deploy-shared-pgsql-sccplus/providers/Microsoft.DBforPostgreSQL/flexibleServers/pgsql-company-we1-nonprod-service-labs-sccplus-001?api-version=2024-08-01
2025-10-15T19:13:53.739+0200 [TRACE] dag/walk: vertex "module.postgresql_flexible_server.output.server_name (expand)" is waiting for "module.postgresql_flexible_server[\"labs-sccplus-001\"].azurerm_postgresql_flexible_server.server"
2025-10-15T19:13:53.739+0200 [TRACE] dag/walk: vertex "module.postgresql_flexible_server.azurerm_postgresql_flexible_server_active_directory_administrator.ad_admin (expand)" is waiting for "module.postgresql_flexible_server[\"labs-sccplus-001\"].azurerm_postgresql_flexible_server.server"
2025-10-15T19:13:53.739+0200 [TRACE] dag/walk: vertex "module.postgresql_flexible_server (close)" is waiting for "module.postgresql_flexible_server.azurerm_management_lock.pgsql (expand)"
2025-10-15T19:13:53.739+0200 [TRACE] dag/walk: vertex "root" is waiting for "provider[\"registry.terraform.io/hashicorp/azurerm\"] (close)"
2025-10-15T19:13:53.739+0200 [TRACE] dag/walk: vertex "module.postgresql_flexible_server.output.server_fqdn (expand)" is waiting for "module.postgresql_flexible_server[\"labs-sccplus-001\"].azurerm_postgresql_flexible_server.server"
2025-10-15T19:13:53.739+0200 [TRACE] dag/walk: vertex "module.postgresql_flexible_server[\"labs-sccplus-001\"].azurerm_postgresql_flexible_server_active_directory_administrator.ad_admin[\"73ba5a92-37cd-458f-a17f-d3784f4db77f\"]" is waiting for "module.postgresql_flexible_server.azurerm_postgresql_flexible_server_active_directory_administrator.ad_admin (expand)"
2025-10-15T19:13:53.739+0200 [TRACE] dag/walk: vertex "module.postgresql_flexible_server.azurerm_management_lock.pgsql (expand)" is waiting for "module.postgresql_flexible_server[\"labs-sccplus-001\"].azurerm_postgresql_flexible_server.server"
2025-10-15T19:13:53.739+0200 [TRACE] dag/walk: vertex "module.postgresql_flexible_server.output.server_id (expand)" is waiting for "module.postgresql_flexible_server[\"labs-sccplus-001\"].azurerm_postgresql_flexible_server.server"
2025-10-15T19:13:54.507+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: [DEBUG] AzureRM Response for https://management.azure.com/subscriptions//resourceGroups/rg-bnl-we1-nonprod-service-deploy-shared-pgsql-sccplus/providers/Microsoft.DBforPostgreSQL/flexibleServers/pgsql-company-we1-nonprod-service-labs-sccplus-001?api-version=2024-08-01:
2025-10-15T19:13:54.507+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: HTTP/2.0 404 Not Found
2025-10-15T19:13:54.507+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: Content-Length: 200
2025-10-15T19:13:54.507+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: Cache-Control: no-cache
2025-10-15T19:13:54.507+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: Content-Type: application/json; charset=utf-8
2025-10-15T19:13:54.507+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: Date: Wed, 15 Oct 2025 17:13:53 GMT
2025-10-15T19:13:54.507+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: Expires: -1
2025-10-15T19:13:54.507+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: Pragma: no-cache
2025-10-15T19:13:54.507+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: Strict-Transport-Security: max-age=31536000; includeSubDomains
2025-10-15T19:13:54.507+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: X-Cache: CONFIG_NOCACHE
2025-10-15T19:13:54.507+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: X-Content-Type-Options: nosniff
2025-10-15T19:13:54.507+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: X-Ms-Correlation-Request-Id: 1ba10015-f24c-4e94-ac9f-b01a08ac547a
2025-10-15T19:13:54.507+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: X-Ms-Operation-Identifier: tenantId=6e06e42d-6925-47c6-b9e7-9581c7ca302a,objectId=43ffb199-78a3-4fed-bce5-a82b8e2cda7f/westeurope/8c23b5ce-ed90-4995-8d0f-4810c00f009d
2025-10-15T19:13:54.507+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: X-Ms-Ratelimit-Remaining-Subscription-Global-Writes: 2999
2025-10-15T19:13:54.507+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: X-Ms-Ratelimit-Remaining-Subscription-Writes: 199
2025-10-15T19:13:54.507+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: X-Ms-Request-Id: b6f21f60-3392-4732-ba55-959c3b82c154
2025-10-15T19:13:54.507+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: X-Ms-Routing-Request-Id: WESTEUROPE:20251015T171354Z:1ba10015-f24c-4e94-ac9f-b01a08ac547a
2025-10-15T19:13:54.507+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: X-Msedge-Ref: Ref A: 14540C50CE3046B19D4FCDF9DF175961 Ref B: CH1AA2020603033 Ref C: 2025-10-15T17:13:53Z
2025-10-15T19:13:54.507+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5
2025-10-15T19:13:54.507+0200 [DEBUG] provider.terraform-provider-azurerm_v4.48.0_x5: {"error":{"code":"ResourceNotFound","message":"The requested resource of type 'Microsoft.DBforPostgreSQL/flexibleServers' with name 'pgsql-company-we1-nonprod-service-labs-sccplus-001' was not found."}}
2025-10-15T19:13:54.507+0200 [TRACE] provider.terraform-provider-azurerm_v4.48.0_x5: Called downstream: @caller=github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:981 @module=sdk.helper_schema tf_mux_provider="*schema.GRPCProviderServer" tf_rpc=ApplyResourceChange tf_provider_addr=registry.terraform.io/hashicorp/azurerm tf_req_id=7d3287c9-2c87-a2c1-8172-07180832674a tf_resource_type=azurerm_postgresql_flexible_server timestamp="2025-10-15T19:13:54.507+0200"
2025-10-15T19:13:54.507+0200 [TRACE] provider.terraform-provider-azurerm_v4.48.0_x5: Received downstream response: tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/tf5serverlogging/downstream_request.go:61 @module=sdk.proto diagnostic_warning_count=0 tf_provider_addr=registry.terraform.io/hashicorp/azurerm tf_req_duration_ms=2183 diagnostic_error_count=1 tf_proto_version=5.10 tf_req_id=7d3287c9-2c87-a2c1-8172-07180832674a tf_resource_type=azurerm_postgresql_flexible_server timestamp="2025-10-15T19:13:54.507+0200"
2025-10-15T19:13:54.507+0200 [ERROR] provider.terraform-provider-azurerm_v4.48.0_x5: Response contains error diagnostic: tf_rpc=ApplyResourceChange diagnostic_detail=""
diagnostic_summary=
| creating Flexible Server (Subscription: "some-id"
| Resource Group Name: "rg-bnl-we1-nonprod-service-deploy-shared-pgsql-sccplus"
| Flexible Server Name: "pgsql-company-we1-nonprod-service-labs-sccplus-001"): performing Create: unexpected status 404 (404 Not Found) with error: ResourceNotFound: The requested resource of type 'Microsoft.DBforPostgreSQL/flexibleServers' with name 'pgsql-company-we1-nonprod-service-labs-sccplus-001' was not found.
tf_proto_version=5.10 tf_provider_addr=registry.terraform.io/hashicorp/azurerm tf_req_id=7d3287c9-2c87-a2c1-8172-07180832674a @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/diag/diagnostics.go:58 @module=sdk.proto diagnostic_severity=ERROR tf_resource_type=azurerm_postgresql_flexible_server timestamp="2025-10-15T19:13:54.507+0200"
2025-10-15T19:13:54.507+0200 [TRACE] provider.terraform-provider-azurerm_v4.48.0_x5: Served request: tf_provider_addr=registry.terraform.io/hashicorp/azurerm tf_req_id=7d3287c9-2c87-a2c1-8172-07180832674a tf_resource_type=azurerm_postgresql_flexible_server tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:957 @module=sdk.proto tf_proto_version=5.10 timestamp="2025-10-15T19:13:54.507+0200"
2025-10-15T19:13:54.508+0200 [TRACE] maybeTainted: module.postgresql_flexible_server["labs-sccplus-001"].azurerm_postgresql_flexible_server.server encountered an error during creation, so it is now marked as tainted
2025-10-15T19:13:54.508+0200 [TRACE] terraform.contextPlugins: Schema for provider "registry.terraform.io/hashicorp/azurerm" is in the global cache
2025-10-15T19:13:54.508+0200 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState to workingState for module.postgresql_flexible_server["labs-sccplus-001"].azurerm_postgresql_flexible_server.server
2025-10-15T19:13:54.508+0200 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState: removing state object for module.postgresql_flexible_server["labs-sccplus-001"].azurerm_postgresql_flexible_server.server
2025-10-15T19:13:54.508+0200 [TRACE] evalApplyProvisioners: module.postgresql_flexible_server["labs-sccplus-001"].azurerm_postgresql_flexible_server.server is tainted, so skipping provisioning
2025-10-15T19:13:54.508+0200 [TRACE] maybeTainted: module.postgresql_flexible_server["labs-sccplus-001"].azurerm_postgresql_flexible_server.server was already tainted, so nothing to do
2025-10-15T19:13:54.508+0200 [TRACE] terraform.contextPlugins: Schema for provider "registry.terraform.io/hashicorp/azurerm" is in the global cache
2025-10-15T19:13:54.508+0200 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState to workingState for module.postgresql_flexible_server["labs-sccplus-001"].azurerm_postgresql_flexible_server.server
2025-10-15T19:13:54.508+0200 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState: removing state object for module.postgresql_flexible_server["labs-sccplus-001"].azurerm_postgresql_flexible_server.server
2025-10-15T19:13:54.508+0200 [DEBUG] State storage *remote.State declined to persist a state snapshot
2025-10-15T19:13:54.508+0200 [ERROR] vertex "module.postgresql_flexible_server[\"labs-sccplus-001\"].azurerm_postgresql_flexible_server.server" error: creating Flexible Server (Subscription: "some-id"
Resource Group Name: "rg-bnl-we1-nonprod-service-deploy-shared-pgsql-sccplus"
Flexible Server Name: "pgsql-company-we1-nonprod-service-labs-sccplus-001"): performing Create: unexpected status 404 (404 Not Found) with error: ResourceNotFound: The requested resource of type 'Microsoft.DBforPostgreSQL/flexibleServers' with name 'pgsql-company-we1-nonprod-service-labs-sccplus-001' was not found.
2025-10-15T19:13:54.509+0200 [TRACE] vertex "module.postgresql_flexible_server[\"labs-sccplus-001\"].azurerm_postgresql_flexible_server.server": visit complete, with errors
2025-10-15T19:13:54.509+0200 [TRACE] dag/walk: upstream of "module.postgresql_flexible_server.azurerm_management_lock.pgsql (expand)" errored, so skipping
2025-10-15T19:13:54.509+0200 [TRACE] dag/walk: upstream of "module.postgresql_flexible_server.output.server_name (expand)" errored, so skipping
2025-10-15T19:13:54.509+0200 [TRACE] dag/walk: upstream of "module.postgresql_flexible_server.output.server_id (expand)" errored, so skipping
2025-10-15T19:13:54.509+0200 [TRACE] dag/walk: upstream of "module.postgresql_flexible_server.azurerm_postgresql_flexible_server_active_directory_administrator.ad_admin (expand)" errored, so skipping
2025-10-15T19:13:54.509+0200 [TRACE] dag/walk: upstream of "module.postgresql_flexible_server.output.server_fqdn (expand)" errored, so skipping
2025-10-15T19:13:54.509+0200 [TRACE] dag/walk: upstream of "module.postgresql_flexible_server[\"labs-sccplus-001\"].azurerm_postgresql_flexible_server_active_directory_administrator.ad_admin[\"73ba5a92-37cd-458f-a17f-d3784f4db77f\"]" errored, so skipping
2025-10-15T19:13:54.509+0200 [TRACE] dag/walk: upstream of "module.postgresql_flexible_server (close)" errored, so skipping
2025-10-15T19:13:54.509+0200 [TRACE] dag/walk: upstream of "provider[\"registry.terraform.io/hashicorp/azurerm\"] (close)" errored, so skipping
2025-10-15T19:13:54.509+0200 [TRACE] dag/walk: upstream of "root" errored, so skipping
2025-10-15T19:13:54.509+0200 [TRACE] terraform.contextPlugins: Schema for provider "registry.terraform.io/hashicorp/azurerm" is in the global cache
2025-10-15T19:13:54.509+0200 [DEBUG] states/remote: state read serial is: 3; serial is: 3
2025-10-15T19:13:54.509+0200 [DEBUG] states/remote: state read lineage is: d9627449-b93a-05ae-5ba9-1ff22b0843e6; lineage is: d9627449-b93a-05ae-5ba9-1ff22b0843e6
2025-10-15T19:13:54.511+0200 [DEBUG] HEAD https://satfstatenonprod19519.blob.core.windows.net/tfstate/bnl-azure-labs-deploy-shared-pgsql-sccplus/env:labs-sccplus-nonprod
2025-10-15T19:13:54.746+0200 [DEBUG] PUT https://satfstatenonprod19519.blob.core.windows.net/tfstate/bnl-azure-labs-deploy-shared-pgsql-sccplus/env:labs-sccplus-nonprod
2025-10-15T19:13:54.956+0200 [DEBUG] HEAD https://satfstatenonprod19519.blob.core.windows.net/tfstate/bnl-azure-labs-deploy-shared-pgsql-sccplus/env:labs-sccplus-nonprod
2025-10-15T19:13:55.145+0200 [DEBUG] HEAD https://satfstatenonprod19519.blob.core.windows.net/tfstate/bnl-azure-labs-deploy-shared-pgsql-sccplus/env:labs-sccplus-nonprod
2025-10-15T19:13:55.339+0200 [DEBUG] PUT https://satfstatenonprod19519.blob.core.windows.net/tfstate/bnl-azure-labs-deploy-shared-pgsql-sccplus/env:labs-sccplus-nonprod?comp=metadata
2025-10-15T19:13:55.543+0200 [DEBUG] PUT https://satfstatenonprod19519.blob.core.windows.net/tfstate/bnl-azure-labs-deploy-shared-pgsql-sccplus/env:labs-sccplus-nonprod?comp=lease
2025-10-15T19:13:55.759+0200 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2025-10-15T19:13:55.775+0200 [INFO] provider: plugin process exited: plugin=.terraform/providers/registry.terraform.io/hashicorp/azurerm/4.48.0/darwin_arm64/terraform-provider-azurerm_v4.48.0_x5 id=55177
2025-10-15T19:13:55.775+0200 [DEBUG] provider: plugin exited
Expected Behaviour
I expect the server to be created.
Actual Behaviour
The apply
command fails almost immediately after it starts the step to create the PostgreSQL Flexible Server with the error:
| creating Flexible Server (Subscription: "some-id"
| Resource Group Name: "rg-bnl-we1-nonprod-service-deploy-shared-pgsql-sccplus"
| Flexible Server Name: "pgsql-company-we1-nonprod-service-labs-sccplus-001"): performing Create: unexpected status 404 (404 Not Found) with error: ResourceNotFound: The requested resource of type 'Microsoft.DBforPostgreSQL/flexibleServers' with name 'pgsql-company-we1-nonprod-service-labs-sccplus-001' was not found.
This is part of a larger code base that I've created and have been improving for 5 years to create PostgreSQL servers in multiple Azure subscriptions.
But when deploying in another new subscription, I get the error above. For troubleshooting, I've successfully created a PostgreSQL via the Azure portal; I've checked if the namespace is registered (yes, it was registered), the user logged in the Azure portal and in the terminal is the same; that user is able to create other resources (such as key vaults, resource groups, storage accounts, etc), and this in the same new subscription.
I've also created a smaller project that only creates the PostgreSQL server, to remove any potential conflicts.
NOTE: I've added partially the debug information because I'm getting a 500 error from GitHub when I'm trying to create or update a gist.

Steps to Reproduce
terraform init
terraform apply
Important Factoids
No response
References
No response