infra/ directory and targets AWS as the primary cloud provider. Frontend sites can also be deployed to Netlify.
Infrastructure-as-code overview
Rather than clicking through the AWS console or writing one-off shell scripts, Bloom uses OpenTofu.tf files to describe all required resources declaratively. Running tofu apply computes the difference between the current state of your AWS account and the desired configuration, then applies only the necessary changes.
The
infra/ codebase is compatible with both OpenTofu and Terraform.Directory structure
tofu_root_modules/ is maintained in forks, not in the core Bloom repo. See the bloom-exygy repository for an example structure.OpenTofu modules
bloom_deployment
The primary importable module. Configures all AWS resources required for a complete Bloom deployment in a single AWS account:
| Terraform file | Resources configured |
|---|---|
vpc.tf | VPC, subnets, routing |
lb.tf | Application Load Balancer |
ecs.tf | ECS cluster |
ecs_api_service.tf | ECS service for the Bloom API (1 vCPU, 2 GiB) |
ecs_site_public_service.tf | ECS service for the public site (2 vCPU, 6 GiB) |
ecs_site_partners_service.tf | ECS service for the partners site (2 vCPU, 4 GiB) |
ecs_dbinit_task.tf | One-off ECS task for DB initialization (0.25 vCPU, 512 MiB) |
ecs_dbseed_task.tf | One-off ECS task for DB seeding (1 vCPU, 4 GiB) |
db.tf | RDS PostgreSQL instance |
s3.tf | S3 buckets |
secrets.tf | AWS Secrets Manager secrets |
ses.tf | SES email configuration |
bloom_deployer_permission_set_policy
Configures the IAM Identity Center permission set policy with the minimum permissions required to deploy Bloom. Used to grant the deployer role access without over-provisioning.
AWS deployment guide
Theinfra/aws_deployment_guide/ directory contains a numbered, step-by-step guide for standing up Bloom in a new AWS organization. Follow the files in order:
Create AWS accounts
Set up the required AWS account structure for your organization (
1_create_aws_accounts.md).Configure IAM Identity Center
Set up SSO and IAM Identity Center for secure, federated access (
2_iam_identity_center_configuration.md).Create Tofu state S3 bucket
Provision the S3 bucket that stores OpenTofu remote state (
3_create_tofu_state_s3_bucket.md).Fork the Bloom repo
Fork the repository to maintain your own root modules and environment-specific configuration (
4_fork_bloom_repo.md).Apply deployer permission set modules
Apply the
bloom_deployer_permission_set_policy module to configure the deployer IAM role (5_apply_deployer_permission_set_tofu_modules.md).7_operations_playbook.md) covers day-two tasks such as rotating secrets and scaling services.
Running OpenTofu
Bloom provides a pre-built infra-dev container image (ghcr.io/bloom-housing/bloom/infra-dev) that includes all required tools: OpenTofu, AWS CLI, bash, and openssl.
Using the infra-dev container
Mount theinfra/ directory and your AWS credentials into the container:
- Runs
aws sso loginfor the selected root module’s profile (unless--skip-sso/-ssis passed). - Runs
tofu initto download provider dependencies (unless--skip-init/-siis passed). - Passes remaining arguments directly to the
tofubinary.
Common OpenTofu commands
Required tools (local development)
If you prefer to run OpenTofu outside the container, install the following:Netlify deployment (frontend sites)
Thesites/public and sites/partners directories each include a netlify.toml configuration file for deploying the Next.js frontend sites to Netlify.
Netlify provides:
- Automated builds on branch push
- Preview deployments for pull requests
- Edge CDN distribution
BACKEND_API_BASE, JURISDICTION_NAME, LANGUAGES).
Architecture considerations
ECS Fargate
All application containers (API, public, partners) run as ECS Fargate tasks. Container resource limits in
docker-compose.yml are kept in sync with the corresponding ECS task definitions.Load balancer
An Application Load Balancer routes traffic to ECS services. Mirrors the nginx
lb container used locally.RDS PostgreSQL
The database runs on RDS. SSL is enabled in production (unlike the local
DB_NO_SSL=TRUE setting).Secrets Manager
Sensitive values such as
APP_SECRET and API keys are stored in AWS Secrets Manager and injected into ECS tasks at runtime.CI validation
Theinfra_ci.yml GitHub Actions workflow runs on every push to main and on pull requests that touch infra/**. It verifies that all .tf files are correctly formatted using tofu fmt -check -diff -recursive.