This project defines and deploys a containerized application infrastructure on AWS using Terraform modules.
The main AWS services covered:
- Amazon ECS (Elastic Container Service) - Cluster and Service for app deployment.
- Amazon ECR (Elastic Container Registry) - Container image storage.
- AWS CodeBuild and CodePipeline - CI/CD Pipeline for automatic build and deployment.
- Amazon API Gateway (HTTP API) - API endpoint integration with services using VPC Link and Service Discovery.
- AWS Cloud Map - Internal service discovery.
terraform/
├── environments/
│ ├── dev/
│ │ ├── main.tf
│ │ ├── variables.tf
│ │ ├── outputs.tf
│ ├── qa/
│ │ ├── main.tf
│ │ ├── variables.tf
│ │ ├── outputs.tf
│ └── prod/
│ ├── main.tf
│ ├── variables.tf
│ ├── outputs.tf
│
├── modules/
│ ├── ecs/
│ │ ├── main.tf
│ │ ├── variables.tf
│ │ ├── outputs.tf
│ ├── ecr/
│ │ ├── main.tf
│ │ ├── variables.tf
│ │ ├── outputs.tf
│ ├── codebuild/
│ │ ├── main.tf
│ │ ├── variables.tf
│ │ ├── outputs.tf
│ ├── codepipeline/
│ │ ├── main.tf
│ │ ├── variables.tf
│ │ ├── outputs.tf
│ ├── apigateway/
│ │ ├── main.tf
│ │ ├── variables.tf
│ │ ├── outputs.tf
│ └── vpc/ (Optional)
│ ├── main.tf
│ ├── variables.tf
│ ├── outputs.tf
├── provider.tf
├── backend.tf
└── versions.tf
- Creates an ECS Cluster.
- Creates ECS Services using AWS Fargate or EC2 launch type.
- Supports Service Discovery with Cloud Map.
- Integrates with API Gateway via VPC Link.
- Creates an ECR repository.
- Supports tagging strategies like
:latest
for image deployments.
- Creates a CodeBuild project to build Docker images.
- Pushes images automatically to ECR.
- Creates a full CI/CD pipeline:
- Source from GitHub/GitLab via CodeStar Connections.
- Build using CodeBuild.
- Deploy image to ECS Service.
- Creates a VPC-integrated API Gateway (HTTP API).
- Connects to ECS Services via Service Discovery (Cloud Map).
- Handles default route
$default
with ANY method forwarding.
- KMS Keys are used for encryption:
- For SSM SecureString parameters.
- For S3 bucket encryption if needed.
- Set AWS credentials (through CLI config, environment variables, or IAM roles).
- Initialize Terraform:
terraform init
- Select workspace (example:
prod
,qa
,dev
):terraform workspace select prod
- Apply changes:
terraform apply
- Highly modular: Components can be deployed independently if needed.
- Environment-specific configurations handled through workspaces and parameter store.
- Secure defaults: Encryption, minimal IAM permissions.
- Production-ready structure.