This repository contains Infrastructure as Code (IaC) to provision and manage AWS ECS (Elastic Container Service) using Fargate as the runtime environment. It also includes additional resources for application deployment, including an RDS database, an ECR repository, and a CI/CD pipeline.
.
├── provision-resources/
│ ├── rds.tf # Scripts to provision RDS database
│ ├── ecr.tf # Setup for Elastic Container Registry
│ ├── pipeline.tf # CI/CD pipeline configuration
├── deployment # ECS cluster and service definitions
- ECS with Fargate: Fully managed container orchestration.
- RDS: Managed database service for storing application data.
- ECR: Secure container registry for storing Docker images.
- CI/CD Pipeline: Automates application deployment.
- Scalability: Easily scales based on workload.
- Security: IAM roles and policies for secure access control.
- AWS CLI installed and configured
- Terraform or AWS CloudFormation (if using Infrastructure as Code)
- Docker (for building container images)
-
Clone the repository
git clone <repository-url> cd <repository-folder>
-
Provision resources
- Navigate to the
provision-resourcesfolder and deploy required infrastructure (RDS, ECR, pipeline):
cd terraform/provision-resources terraform init terraform plan terraform apply - Navigate to the
-
Deploy ECS with Fargate
- Configure the ECS cluster and services in the
deployment/directory.
cd terraform/deployment terraform init terraform plan terraform apply - Configure the ECS cluster and services in the
-
Push container image to ECR
aws ecr get-login-password --region <region> | docker login --username AWS --password-stdin <ecr-repo-url> docker build -t <image-name> . docker tag <image-name>:latest <ecr-repo-url>:latest docker push <ecr-repo-url>:latest
-
Trigger the CI/CD pipeline
- The pipeline will deploy the application automatically.
- CloudWatch Logs: View logs for ECS tasks and services.
- AWS X-Ray: Trace application performance (if enabled).
- ECS Console: Monitor running tasks and services.
- Add autoscaling for ECS tasks
- Implement Blue/Green deployment strategy
- Enhance security with AWS Secrets Manager
Feel free to contribute and enhance this repository!