You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Deploys PgDog on AWS ECS. Both Fargate and EC2 clusters are supported, with Fargate used by default.
Features
✔️ ECS service with load balancer and CPU autoscaling
✔️ Secure configuration storage in Secrets Manager
✔️ PgDog logs and metrics export to CloudWatch
✔️ Automatic RDS instance detection, including Aurora readers & writer
✔️ Guaranteed QoS with preconfigured CPU and memory requirements
Quick start
Add this module to your Terraform workspace. If you have an existing RDS Postgres or Aurora database, the module can import it automatically and add it to the [[databases]] section in pgdog.toml, for example:
module"pgdog" {
source="github.com/pgdogdev/pgdog-ecs-terraform?ref=v0.1.0"# The module will automatically detect all instances# and add them to pgdog.toml.aurora_clusters=[
{
cluster_identifier ="aurora-cluster-name"
database_name ="postgres"
}
]
# Users need to be configured manually.users=[
{
name ="postgres"
database ="postgres"# Must match database_name above.# Password is securely stored in AWS Secrets Manager.
password_secret_arn = aws_secretsmanager_secret.postgres_user_password.arn
}
]
# You have a ECS cluster already?ecs_cluster_arn="arn:aws:ecs:us-west-2:1234567890:cluster/your-fargate-ecs-cluster"# Networking configuration.vpc_id="vpc-xxxxxxxxxx"subnet_ids=["subnet-xxxxxxxxxx", "subnet-yyyyyyyyyyy"]
pgdog={
# PgDog version.
image_tag ="v0.1.29"# Configure any pgdog.toml settings directly in TF.
general = {
workers =2
}
}
}
The password for each user needs to be stored in Secrets Manager. You can do so manually or by using Terraform:
resource"aws_secretsmanager_secret""postgres_user_password" {
name="your-pgdog-deployment/postgres-password"
}
resource"aws_secretsmanager_secret_version""postgres_user_password" {
secret_id=aws_secretsmanager_secret.postgres_user_password.id# Store the password in Vault or another secrets manager, e.g. 1Password.secret_string="${data.vault_kv_secret_v2.db.data["password"]}"
}
Dependencies
Tasks created by the ECS service require access to the Internet to download container images and push metrics and logs to CloudWatch. To make this work out of the box, you have two options:
Use privatesubnet_ids which have an attached NAT gateway
Use publicsubnet_ids and assign ECS tasks public IPs by configuring assign_public_ip = true
Failure to do either will produce confusing errors at task creation, since it won't be able to log errors to CloudWatch or pull container images.
Managed resources
Resource
Description
ECS Cluster
Optional, only if ecs_cluster_arn not provided.
ECS task definition
PgDog container, init container to setup configuration, and optional ADOT sidecar to export Prometheus metrics to CloudWatch.
ECS service
Supports deployment circuit breaker and rolling deployments.
Network load balancer
Your application will connect to the load balancer.
Security group
For controlling ingress to ECS tasks.
IAM Roles
Automatically configured task execution and task runtime roles.
Secrets Manager Secrets
Storing pgdog.toml and users.toml configuration files.
CloudWatch Log Group
PgDog container logs.
Autoscaling
Target and policies (CPU/memory-based).
Variables
General
Name
Description
Type
Default
Required
name
Name prefix for all resources
string
-
yes
create_resources
Whether to create AWS resources (set to false for config-only testing)
# Self-signed certificate (generated on boot)tls_mode="self_signed"# Certificate from Secrets Managertls_mode="secrets_manager"tls_certificate_secret_arn="arn:aws:secretsmanager:us-east-1:123456789:secret:pgdog-cert"tls_private_key_secret_arn="arn:aws:secretsmanager:us-east-1:123456789:secret:pgdog-key"