AzureAzure Database for PostgreSQLDatabase

azurerm_postgresql_flexible_server cost estimation

A managed PostgreSQL server. Priced by compute SKU, storage size, and high-availability mode.

An azurerm_postgresql_flexible_server is a managed PostgreSQL database. It replaces the older Single Server tier and is the recommended choice for new deployments. Pricing has three main parts.

First, compute. The server's SKU determines per-hour cost. Three tiers: Burstable (B-series, cheap, for low-baseline workloads), General Purpose (Dsv3-series, balanced), and Memory Optimized (Esv3-series, more RAM per vCPU). Within each tier, you pick a size. A B2s costs ~$0.034/hour ($25/month); a D4s_v3 costs ~$0.27/hour ($197/month).

Second, storage. Provisioned size from 32 GB to 16 TB, billed at $0.115/GB-month for general-purpose SSD. IOPS scale automatically with size (or with the iops_tier attribute for premium tiers). Storage cannot be reduced after provisioning, only increased.

Third, high availability. Three options: None (single server, default), SameZone (same-zone replica for ~2x compute cost), ZoneRedundant (cross-zone replica for ~2x compute cost). Replicas add the same hourly compute price as the primary, effectively doubling the bill.

Backup storage is free up to 100% of provisioned storage, then billed per GB-month. Point-in-time restore is available with backup retention up to 35 days.

c3x reads sku_name, storage_mb, and high_availability config from the Terraform resource.

Terraform example

A minimal but realistic configuration that C3X can estimate.

resource "azurerm_postgresql_flexible_server" "main" {
  name                          = "production-postgres"
  resource_group_name           = azurerm_resource_group.main.name
  location                      = "eastus"
  version                       = "16"
  sku_name                      = "GP_Standard_D2s_v3"
  storage_mb                    = 131072
  storage_tier                  = "P10"
  backup_retention_days         = 14
  geo_redundant_backup_enabled  = false
  administrator_login           = "psqladmin"
  administrator_password        = var.db_password

  high_availability {
    mode = "ZoneRedundant"
  }
}

Pricing dimensions

What you actually pay for when you provision azurerm_postgresql_flexible_server.

DimensionUnitWhat's being charged
Compute hoursper hourRate for the server SKU. Multiplied for HA replicas (doubles cost).
$0.27/hour for GP_Standard_D2s_v3 in eastus
Storageper GB-monthProvisioned storage. Cannot be reduced after creation. P-tier (Premium SSD) and PV2-tier (Premium SSD v2) have different per-GB rates.
$0.115/GB-month general-purpose
Backup storage (above 100% of provisioned)per GB-monthBackups up to provisioned size are free. Anything above is billed. Geo-redundant backups bill at higher rate.
High availability replicamultiplierZoneRedundant or SameZone HA provisions a hot standby. Effectively doubles compute cost.

Optimization tips

Common ways to reduce azurerm_postgresql_flexible_server cost without changing the workload.

Use Burstable (B-series) for non-production

Up to 80%

B-series uses a credit-based CPU model and costs 70-80% less than General Purpose at the same advertised vCPU count. Right for dev, staging, and any workload with low average CPU.

Skip HA for non-production environments

About 50% on compute

Zone-Redundant HA doubles compute cost. Non-production typically doesn't need 99.99% SLA. Disabling HA for dev/staging cuts compute spend in half.

Buy reserved capacity for steady-state

30-60%

Azure Reserved Capacity for PostgreSQL cuts compute prices by 30-60% with a 1- or 3-year commitment. Right for production databases that won't move.

Use Postgres connection pooling (PgBouncer)

Workload-dependent

Flexible Server has built-in PgBouncer support. Enabling it lets a smaller SKU handle more clients than running connections directly to Postgres. Sometimes lets you downsize compute.

FAQ

Should I use Flexible Server or Single Server?

Flexible Server. Single Server is deprecated and being retired. Flexible Server has better pricing, more features (HA, read replicas, server parameter tuning), and is the active product line.

How does c3x handle read replicas?

Read replicas (azurerm_postgresql_flexible_server with create_mode = 'Replica') are separate resources. Each one is billed at its own compute + storage rate. c3x estimates each replica independently.

Are backups really free?

Up to 100% of provisioned storage. A 1 TB server gets 1 TB of free backup. Beyond that, you pay per GB-month. Geo-redundant backup (geo_redundant_backup_enabled = true) is billed at a higher rate for the cross-region copy.

What about Premium SSD v2 storage?

PSSDv2 is a newer storage tier with separate IOPS and throughput provisioning. Cheaper per GB but you pay extra for IOPS and MB/s. Right for high-performance workloads. c3x picks up the storage_tier attribute.

Related resources

Estimate this resource in your own Terraform

Free, open source, no API key. C3X parses your Terraform and shows line-item cost for every resource, including azurerm_postgresql_flexible_server.