azurerm_postgresql_flexible_server

Manages a PostgreSQL Flexible Server.

Example Usage

provider "azurerm" {
  features {}
}

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "West Europe"
}

resource "azurerm_virtual_network" "example" {
  name                = "example-vn"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  address_space       = ["10.0.0.0/16"]
}

resource "azurerm_subnet" "example" {
  name                 = "example-sn"
  resource_group_name  = azurerm_resource_group.example.name
  virtual_network_name = azurerm_virtual_network.example.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" "example" {
  name                = "example.postgres.database.azure.com"
  resource_group_name = azurerm_resource_group.example.name
}

resource "azurerm_private_dns_zone_virtual_network_link" "example" {
  name                  = "exampleVnetZone.com"
  private_dns_zone_name = azurerm_private_dns_zone.example.name
  virtual_network_id    = azurerm_virtual_network.example.id
  resource_group_name   = azurerm_resource_group.example.name
  depends_on            = [azurerm_subnet.example]
}

resource "azurerm_postgresql_flexible_server" "example" {
  name                   = "example-psqlflexibleserver"
  resource_group_name    = azurerm_resource_group.example.name
  location               = azurerm_resource_group.example.location
  version                = "12"
  delegated_subnet_id    = azurerm_subnet.example.id
  private_dns_zone_id    = azurerm_private_dns_zone.example.id
  administrator_login    = "psqladmin"
  administrator_password = "H@Sh1CoR3!"
  zone                   = "1"

  storage_mb   = 32768
  storage_tier = "P30"

  sku_name   = "GP_Standard_D4s_v3"
  depends_on = [azurerm_private_dns_zone_virtual_network_link.example]

}

Arguments Reference

The following arguments are supported:


An authentication block supports the following:


A customer_managed_key block supports the following:


An identity block supports the following:


A maintenance_window block supports the following:


A high_availability block supports the following:


storage_tier defaults based on storage_mb

storage_mb GiB TiB Default Supported storage_tier's Provisioned IOPS
32768 32 - P4 P4, P6, P10, P15, P20, P30, P40, P50 120
65536 64 - P6 P6, P10, P15, P20, P30, P40, P50 240
131072 128 - P10 P10, P15, P20, P30, P40, P50 500
262144 256 - P15 P15, P20, P30, P40, P50 1,100
524288 512 - P20 P20, P30, P40, P50 2,300
1048576 1024 1 P30 P30, P40, P50 5,000
2097152 2048 2 P40 P40, P50 7,500
4193280 4095 4 P50 P50 7,500
4194304 4096 4 P50 P50 7,500
8388608 8192 8 P60 P60, P70 16,000
16777216 16384 16 P70 P70, P80 18,000
33553408 32767 32 P80 P80 20,000

Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

Import

PostgreSQL Flexible Servers can be imported using the resource id, e.g.

terraform import azurerm_postgresql_flexible_server.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.DBforPostgreSQL/flexibleServers/server1