Skip to main content

PostgreSQL Application Guide

This guide covers running PostgreSQL as a containerized application. To give another application a managed database, use its provisionDatabase settings instead (see the Database Deployment Guide).

Status: Available (not yet verified end to end)


Quick Reference​

PropertyValue
Application IDpostgresql
CategoryDatabase
Default Imagepostgres:15
Application Port5432
Default CPU1024 (Fargate)
Default Memory2048 MB (Fargate)
Default Instancet3.small (EC2)
Health Check Path/
Health Check Grace300 seconds
Supports FargateYes
Supports EC2Yes
Supported Auth Modesnone
Database RequiredN/A (is a database)

When to Use​

A containerized PostgreSQL instance is suited to development, testing, and prototyping.

For production data, consider Amazon RDS for PostgreSQL, which provides automated backups, Multi-AZ deployment, read replicas, and managed patching.


Storage Configuration​

Container (Fargate)​

PropertyValue
Data Path/var/lib/postgresql/data
EFS Path/postgresql
Volume NamepostgresData
Container User999:999
EFS Permissions700

On EC2, data is stored under /var/lib/postgresql/data.


Deployment Context Examples​

Development​

{
"stackName": "PostgreSQL-Dev",
"applicationId": "postgresql",
"applicationName": "PostgreSQL Dev",
"environment": "dev",

"runtime": "fargate",
"securityProfile": "dev",
"topology": "application-service",

"networkMode": "private-with-nat",
"region": "us-east-1",

"authMode": "none",

"cpu": 1024,
"memory": 2048,

"enableMonitoring": true,
"logRetentionDays": "7"
}

Environment Variables​

The EC2 user data starts the container with these variables. The Fargate task definition does not set them; the postgres image requires POSTGRES_PASSWORD (or an explicit trust setting) to initialize.

VariableValue (EC2)
POSTGRES_PASSWORDRead from the Secrets Manager secret <stack name>/password if it exists; otherwise generated with openssl rand
POSTGRES_DBcloudforge
POSTGRES_USERcloudforge

When the password is generated, it is also written to /var/log/userdata.log on the instance. Rotate it after first sign-in.


Compliance Considerations​

Databases often hold regulated data (PII, PHI, payment data). Compliance frameworks typically expect encryption at rest and in transit, access audit logging, and backup retention that matches the framework's requirements.

For regulated workloads, Amazon RDS offers Multi-AZ deployment, encryption, Enhanced Monitoring, Performance Insights, and automated backups.