This directory contains Terraform modules and a deployment script for provisioning the sample's Azure resources. For details about the sample application, see Azure Web App with Azure Database for PostgreSQL flexible server.
- LocalStack for Azure
- Terraform (1.5+)
- Docker
- Azure CLI + Azlocal CLI
- Python 3.12+
- PostgreSQL client (
psql) jq
pip install azlocalThe Terraform configuration provisions:
- Azure Resource Group.
- Azure Virtual Network with two subnets:
- app-subnet (delegated to
Microsoft.Web/serverFarmsfor the Web App's VNet integration) - pe-subnet (hosts the Private Endpoint to the flex server)
- app-subnet (delegated to
- Azure Private DNS Zone
privatelink.postgres.database.azure.com, linked to the VNet. - Azure Private Endpoint (group
postgresqlServer). - Azure NAT Gateway.
- Network Security Groups: one per subnet.
- Azure Log Analytics Workspace.
- Azure Database for PostgreSQL flexible server: public-access mode, Burstable
Standard_B1ms, version 16, 32 GiB, HA disabled. A permissive firewall rule (AllowAllIPs,0.0.0.0–255.255.255.255) lets the deploy machine reach the server for the post-apply psql bootstrap. - PostgreSQL database
PlannerDB. - Azure App Service Plan.
- Azure Web App with regional VNet integration.
PG_HOST/PG_PORT/PG_DATABASEare written by Terraform;PG_USERandPG_PASSWORDare written bydeploy.shafter psql creates the application role.
deploy.sh performs:
terraform init -upgradeterraform plan -out=tfplan(passingpg_admin_password)terraform apply -auto-approve tfplan- Reads outputs (
resource_group_name,web_app_name,postgres_server_name,postgres_fqdn,postgres_database_name). - Connects to the server as the admin via the public endpoint + firewall rule and creates the
testuserrole, grants schema rights, creates theactivitiestable, and seeds three rows. - Sets
PG_USER=testuser+PG_PASSWORD=<app-password>on the Web App viaaz webapp config appsettings set. - Zips the source under
../srcand deploys viaaz webapp deploy.
Override any of the variables in variables.tf by editing terraform.tfvars or passing -var to terraform plan. Notable PostgreSQL ones:
| Variable | Default | Description |
|---|---|---|
pg_admin_login |
pgadmin |
Server administrator login |
pg_admin_password |
P@ssw0rd1234! |
Server administrator password (sensitive) |
pg_version |
16 |
PostgreSQL major version |
pg_sku_name |
B_Standard_B1ms |
Compute SKU |
pg_storage_mb |
32768 |
Storage size in MB |
pg_backup_retention_days |
7 |
Backup retention |
pg_database_name |
PlannerDB |
Application database |
For non-dev deployments, set pg_admin_password via env var: PG_ADMIN_PASSWORD=... bash deploy.sh.