This repository contains the source code and IaC configurations for an example application written in Ruby on Rails (ROR). The repository is structured to facilitate CI/CD using GitHub Actions.
The application is deployed to AWS ECS and relies on MySQL 8.0
RDS for its database.
The CI/CD pipeline is responsible for building, testing and creating a container image, storing it in ECR, and deploying to ECS.
Load balancing for the application is handled with ALB
-
Application:
The ROR example blog application source code is located in the root directory. Ruby version:
3.2.2
-
GitHub Actions Workflow:
The CI/CD pipeline configuration is stored in the
.github/workflows
directory. -
Terraform Infrastructure: Terraform version used:
v1.5.7
Infrastructure configurations for deploying the application are divided into two parts:- Initial manual configurations:
terraform/manual
- Automated configurations:
terraform/auto
- Initial manual configurations:
-
Database: MySQL
v8.0
RDS -
Monitoring ECS has enabled CloudWatch monitoring
-
Scalability The application is deployed to AWS Elastic Container Service (ECS), and load balancing is achieved using an Application Load Balancer (ALB). Application automatically scales according to the CPU/Mem consumption
-
GitHub Actions Secrets: Credentials and other sensitive information used in the GitHub Actions workflows are securely stored as secrets within GitHub.
CI/CD process performs the following steps:
-
Build: The application code is built and dependencies are installed.
-
Test: Unit tests, integration tests, or any other specified tests are executed.
-
Docker Image Creation: A Docker container image is created, and the application code is bundled into it.
-
Amazon ECR: The container image is pushed to Amazon Elastic Container Registry (ECR).
-
ECS Deployment: The new container image is deployed to AWS ECS, ensuring the application is up-to-date.
Commit/PR -> Trigger build -> Build -> Test -> Deliver build to ECR -> Terraform updates ECS
The Terraform configurations are divided into two parts for ease of management:
-
Manual Part (
terraform/manual
): Contains configurations that require manual intervention or setup. This include VPC, RDS DB and ECS cluster. -
Automated Part (
terraform/auto
): Includes automated configurations that are used for provisioning. This include ECS, security groups, container definition and ALB.