Estimated AWS costs for a small production workload (2 Fargate tasks each for backend and frontend, a
db.t3.medium RDS instance, one NAT Gateway, and an ALB) are roughly $50–100 per month. Costs scale with traffic, task count, and data transfer. Use the AWS Pricing Calculator to estimate your specific configuration before deploying.Prerequisites
Before running Terraform, make sure you have the following installed and configured on your machine:- AWS CLI configured with credentials that have sufficient IAM permissions to create VPCs, ECS clusters, RDS instances, ECR repositories, and IAM roles. Run
aws sts get-caller-identityto verify your credentials. - Terraform 1.5 or later. Run
terraform versionto check. - Docker, for building and pushing your backend and frontend images to ECR.
What the Terraform modules provision
The modules inproducts/enterprise/infra/terraform/ create the following AWS resources:
Initialize and deploy
1
Navigate to the Terraform directory
2
Create your tfvars file
Copy the example variables file and fill in your values:Open You can also override instance sizes, task counts, and auto-scaling limits. Refer to
terraform.tfvars and set at minimum:variables.tf for the full list of inputs and their defaults.3
Initialize Terraform
backend "s3" block in main.tf with your bucket name and key.4
Preview the plan
5
Apply the configuration
yes when prompted. The apply takes approximately 10–15 minutes, with the RDS instance taking the longest to become available. When it completes, Terraform prints the ALB DNS name, ECR repository URLs, and RDS endpoint as outputs.Pushing Docker images
Afterterraform apply succeeds, build your images locally and push them to the ECR repositories Terraform created. The repository URLs are available in the Terraform outputs.
<backend-ecr-url> and <frontend-ecr-url> with the values from the backend_ecr_url and frontend_ecr_url Terraform outputs. After pushing, force a new deployment so ECS pulls the updated images:
Running migrations on AWS
You need to run Alembic migrations whenever you deploy a new schema version. There are two common approaches. Run migrations as a one-off ECS task. Use the AWS CLI to start a task that overrides the container command with the Alembic upgrade command:private_subnet_ids and the ECS tasks security group).
Use a bastion host for interactive access. If you prefer to connect directly to the database, launch a small EC2 instance in a public subnet within the same VPC, configure its security group to allow inbound SSH, and add a rule to the RDS security group allowing connections from the bastion instance on port 5432. You can then SSH in and run Alembic from there.
For automated deployments, the ECS task approach is recommended because it requires no additional infrastructure and uses the same Docker image as your running service.