Web Application CI/CD using AWS and Github Actions
DevOps
Project details
Description
This project demonstrates the CI/CD pipeline of a web application from the
provisioning of its resources to the deployment of the application. For this project, a random react
application template has been downloaded.
Nowadays, before deploying a web application to production, it needs to be tested,
so the project will demonstrate the pipeline in both a staging (testing) and production
environment.In the staging environment, the application is deployed to Amazon Elastic Compute Cloud
(EC2) and the necessary services are provisioned using AWS CloudFormation.When testing is complete
and features are validated, the application is then containerised and pushed to Amazon Elastic
Container Registry (ECR), where the container is pulled by Amazon Elastic Container Service (ECS)
for production.
TOOLS USED
- Node.js
- Reactjs
- Github Actions
- Docker
- Amazon EC2
- Amazon ECR
- Amazon ECS
- Amazon IAM
- AWS CloudFormation
Challenges
Before performing the CI/CD of an application, we need to understand its
nomenclature and challenges. Some common challenges include:
- Environment Configuration:Manage the difference between development, staging and production environments
- Dependency Management:Ensure all dependencies are correctly versioned and manage potential conflicts between environments
- Security:Securing sensitive data such as API keys, passwords and certificates in the pipelines
- Deployment Strategy:Choose between strategies such as blue-green deployments and canary releases to ensure zero downtime during deployment
- Rollback Mechanism:Design efficient rollback strategies in the event that a deployment experiences errors or failures.
- Tool Integration:Selecting and integrating the right tools for version control, build automation, test frameworks and deployment platforms, and managing compatibility issues between tools.
Steps Taken
Deployment of the web application takes place in two separate environments, each
with different steps:
- Staging (test) environment:The staging environment
uses few AWS services to minimise costs:
- The code will be pushed to github
- Github Actions configure the provided AWS credentials
- The cloud stack is deployed using the Cloudformation template.
- The project dependencies are built
- The project is build for deployment
- Github Actions SSH to AWS EC2 created as part of the cloud stack
- The built file are push to EC2
- EC2 is configured and the application is made available to the public.
- Production Environment:Due to the nature of the environment, the production stack is deployed in two separate templates: the first template configures the network infrastructure and the repository required to store the Docker image, and the second template provides the available services to deploy the application into production.