# Azure Postgres flexible server not able to PointInTimeRestore

**URL:** <https://discuss.hashicorp.com/t/azure-postgres-flexible-server-not-able-to-pointintimerestore/59348>\
**Category:** Azure\
**Tags:** azure\
**Created:** [October 20, 2023, 11:16am UTC](https://discuss.hashicorp.com/t/azure-postgres-flexible-server-not-able-to-pointintimerestore/59348 "2023-10-20T11:16:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkuchniak](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/mkuchniak/32/38466_2.png) [@mkuchniak](https://discuss.hashicorp.com/u/mkuchniak)\
**Post date:** [October 20, 2023, 11:16am UTC](https://discuss.hashicorp.com/t/azure-postgres-flexible-server-not-able-to-pointintimerestore/59348/1 "2023-10-20T11:16:00Z")

</div>

Hi,

I’m using Terraform as IaC for our Azure cloud, and working on DR scripts for Terraform. As one of the steps, we want to restore postgres flexible server instances in another region. I’m trying to use PointInTimeRestore creat\_mode in the module azurerm\_postgresql\_flexible\_server but it fails with 404 error, can’t find the source server.

Terraform version: 1.6.3  
Azurerm: 3.77.0

My terraform code:

```auto
resource "azurerm_postgresql_flexible_server" "psql" {
  name = var.psql_name
  resource_group_name = azurerm_resource_group.rg.name
  location = azurerm_resource_group.rg.location
  version = var.psql_version
  create_mode = "PointInTimeRestore"
  source_server_id = "/subscriptions/my-sub-id/resourceGroups/main-db-rg/providers/Microsoft.DBforPostgreSQL/flexibleServers/psql-main-db"
  point_in_time_restore_time_in_utc = "2023-10-19T10:59:50.154333Z"
  backup_retention_days = var.psql_backup_retention_days
  sku_name = var.psql_sku
  storage_mb = var.psql_storage
  delegated_subnet_id = data.azurerm_subnet.postgres_sn.id
  private_dns_zone_id = data.azurerm_private_dns_zone.postgres_priv_dns.id
  tags = var.tags
}

```

When I run the terraform I get:

```auto
 Error: creating Flexible Server (Subscription: "my-sub-id"
 Resource Group Name: "rg-myrg-01"
 Flexible Server Name: "psql-restore-main-db"): performing Create: unexpected status 404 with error: ResourceNotFound: The requested resource of type 'Microsoft.DBforPostgreSQL/flexibleServers' with name 'psql-main-db' was not found.

with azurerm_postgresql_flexible_server.activity_psql,
on postgres.tf line 1, in resource "azurerm_postgresql_flexible_server" "psql":
 1: resource "azurerm_postgresql_flexible_server" "psql" {

```

I can create a replica just fine by replacing PointInTimeRestore with Replica and removing point\_in\_time\_restore\_time\_in\_utc.

Is anyone facing this problem as well?
