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

Getting error of source server not found while doing restore of azure postgres flexible server in same region #27917

Open SwapnilB19 opened 3 weeks ago

SwapnilB19 commented 3 weeks ago

Is there an existing issue for this?

Community Note

Terraform Version

1.2.4

AzureRM Provider Version

3.109.0

Affected Resource(s)/Data Source(s)

azurerm_postgresql_flexible_server, azapi_resource

Terraform Configuration Files

provider "azurerm" {
  features {}
  subscription_id = "my-sub-id"
}

# Flexible Server creation using point-in-time restore
resource "azurerm_postgresql_flexible_server" "restored_server" {
  name                   = "sameregionrestoreserver"
  location               = "westeurope"
  storage_mb             = "131072"
  sku_name               = "GP_Standard_D2ds_v4"
  resource_group_name    = "same-resource-group"
  backup_retention_days        = 7
  geo_redundant_backup_enabled = true
  create_mode            = "GeoRestore"
  source_server_id       = "/subscriptions/my-sub-id/resourceGroups/source-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/source-server-name"
  point_in_time_restore_time_in_utc  = "2024-11-06T13:15:21.000Z"
}

Debug Output/Panic Output

ERROR running: terraform apply -auto-approve -no-color  : 
Error: creating/updating "Resource: (ResourceId \"/subscriptions/****/resourceGroups/same-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/sameregionrestoreserver\" / Api Version \"2024-11-01-preview\")": PUT https://management.azure.com/subscriptions/****/resourceGroups/same-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/sameregionrestoreserver
--------------------------------------------------------------------------------
RESPONSE 404: 404 Not Found
ERROR CODE: ResourceNotFound
--------------------------------------------------------------------------------
 {
    "error": {
      "code": "ResourceNotFound",
      "message": "The requested resource of type 'Microsoft.DBforPostgreSQL/flexibleServers' with name 'source-server-name' was not found."
    }
  }
 --------------------------------------------------------------------------------

Expected Behaviour

Restore operation should complete successful in same region.

Actual Behaviour

Failing to restore in same region.

Steps to Reproduce

I am trying to do restore of azure flexible postgres server on which geo redundant backup is enabled. From azure portal able to restore in same region instead of paired region. But from terraform I am getting error while running terraform.

Important Factoids

No response

References

No response

neil-yechenwei commented 2 weeks ago

Thanks for raising this issue. Azure Portal indicates that geoRestore doesn't support them in same region.

image

SwapnilB19 commented 2 weeks ago

I have tried using create_mode = "PointInTimeRestore" for same region, it worked fine and able to restore the database in same region. When we want to use the backup in the same region, we should use PITR and when we need the backup in different region we should use "GeoRestore" in case of disaster.