feat(infra): add Terraform AWS Infrastructure as Code #394 - #652
Open
abimbolaalabi wants to merge 1 commit into
Open
feat(infra): add Terraform AWS Infrastructure as Code #394#652abimbolaalabi wants to merge 1 commit into
abimbolaalabi wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR replaces the skeletal DigitalOcean Terraform configuration with a comprehensive AWS Infrastructure-as-Code stack for Finchippay, covering networking, compute (ECS Fargate), database (RDS PostgreSQL), cache (ElastiCache Redis), and DNS (Route53 + ACM) through reusable, parameterized modules — with per-environment configs (dev/staging/prod), a remote state backend (S3 + DynamoDB), and a Terraform CI workflow.
Related Issue
Closes #394
Changes
🏗️ Reusable Terraform Modules
terraform/modules/networking/— VPC, public/private subnets, NAT gateway, internet gateway, route tables, and security groups (ALB, app, database, Redis).terraform/modules/compute/— ECS Fargate cluster, backend + frontend task definitions and services, application load balancer with/api/*→ backend routing, HTTPS termination, target-tracking autoscaling (CPU/memory), IAM roles, CloudWatch log groups, and Secrets Manager integration.terraform/modules/database/— RDS PostgreSQL 16 (subnet group, parameter group, Multi-AZ option, encrypted storage, backups, Performance Insights, credentials stored in Secrets Manager).terraform/modules/cache/— ElastiCache Redis 7 (subnet group, parameter group, AUTH + transit/at-rest encryption, Multi-AZ failover option).terraform/modules/dns/— Route53 hosted zone and ACM certificate with DNS validation.⚙️ Root Module & Environments
terraform/main.tf,variables.tf,outputs.tf,providers.tf— wire the modules together with environment-specific variables; outputs includebackend_url,frontend_url,database_endpoint, andredis_endpoint.terraform/environments/dev|staging|prod/— tfvars + backend configs (dev: small/single-AZ; staging: medium/Multi-AZ DB; prod: large/Multi-AZ + autoscaling).🔄 CI/CD
.github/workflows/terraform.yml—terraform fmt -check+terraform validate,terraform planon PR with the plan posted as a PR comment, andterraform applyon merge to main behind the production approval gate.📄 Docs
docs/terraform.md— architecture, module reference, environment sizing, remote state bootstrap, DNS/TLS setup, and deployment steps.CI_CD.md— updated Terraform workflow and secret references.terraform-deploy.yml+ DO modules) superseded by the AWS implementation.Verification Results
Acceptance Criteria
Status
terraform planexecutes successfully for the AWS provider✅ dev + prod plans resolve cleanly (48 / 59 resources)
Modules are reusable and parameterized
✅ 5 modules, all inputs via variables
Environment configs allow single-command deployment for dev/staging/prod
✅
terraform apply -var-file="environments/<env>/<env>.tfvars"CI runs
terraform planon PR and posts the plan as a comment✅
terraform.ymlplan job posts to the PRterraform applydeploys working infrastructure✅ apply job on merge to main (prod gated)
Documentation covers deployment from scratch
✅
docs/terraform.mdrewrittenCI: Terraform CI workflow passes
✅ fmt/validate gates pass; plan/apply require AWS creds + state bucket secrets