Welcome to the City Direction Web App Deployment project repository! This repository contains the code and resources needed to deploy a static web application providing directions between cities on Amazon Web Services (AWS).
-
Part-1: CodeCommit Setup
- Contains scripts and resources for setting up version control using AWS CodeCommit.
-
Part-2: CodeBuild Implementation
- Includes configurations and files for automating builds with AWS CodeBuild.
-
Part-3: CodeDeploy and Pipeline Automation
- Contains deployment scripts and instructions for automating deployments with AWS CodeDeploy and CodePipeline.
To clone this repository to your local machine, follow these steps:
- Open your terminal or command prompt.
- Navigate to the directory where you want to clone the repository.
- Use the following command to clone the repository:
git clone (https://github.com/TheMannu/Project-AWS-Devops.git)
In this project we will create a CI/CD pipeline for your static web application using AWS DevOps-related services.
Our project involves a simple static web application that finds routes between cities using Google Maps. The goal is to automate its deployment on AWS using CodePipeline, CodeCommit, CodeBuild, and CodeDeploy.
- CodeCommit: AWS version control service where we'll push our local code.
- CodeBuild: Takes the code from CodeCommit, builds it, and stores artifacts in an S3 bucket.
- S3: Stores build artifacts.
- CodeDeploy: Deploys the application on an EC2 instance.
- An AWS account.
- An IAM user with necessary permissions.
-
Create a CodeCommit Repository:
- Go to AWS Console > CodeCommit > Create Repository.
- Name it
my-direction-app
. - Optional: Add description and tags.
-
Push Local Files to CodeCommit:
- Initialize a Git repository locally:
git init
. - Add remote:
git remote add origin <CodeCommit repository URL>
. - Push code:
git add . git commit -m "Initial commit" git push origin master
- Initialize a Git repository locally:
-
Create an S3 Bucket:
- Name it
my-direction-app-bucket
.
- Name it
-
Create a Build Project in CodeBuild:
- Go to AWS Console > CodeBuild > Create Build Project.
- Name it
my-direction-app
. - Choose
AWS CodeCommit
as the source, select your repository and branch. - Environment: Use a managed image (Ubuntu standard).
- Service role: Create a new role or use an existing one with necessary permissions.
-
Buildspec.yml:
version: 0.2 phases: install: commands: - sudo apt-get update -y - sudo apt-get install -y nginx build: commands: - sudo cp index.html /var/www/html/ post_build: commands: - echo "Build completed" artifacts: files: - '**/*'
-
Start the Build:
- Go to CodeBuild and start the build.
- Check the build logs to ensure it completes successfully.
-
Create an EC2 Instance:
- Name it
my-direction-app-instance
. - Choose an Amazon Linux 2 AMI.
- Assign an IAM role with CodeDeploy permissions.
- Name it
-
Create a CodeDeploy Application and Deployment Group:
- Go to CodeDeploy > Create Application > Name it
my-direction-app
. - Create a deployment group, select the EC2 instance.
- Go to CodeDeploy > Create Application > Name it
-
Appspec.yml:
version: 0.0 os: linux files: - source: / destination: /var/www/html/ hooks: BeforeInstall: - location: scripts/install_dependencies.sh timeout: 300 runas: root AfterInstall: - location: scripts/start_server.sh timeout: 300 runas: root
-
Deployment Scripts:
install_dependencies.sh
:#!/bin/bash sudo apt-get update -y sudo apt-get install -y nginx
start_server.sh
:#!/bin/bash sudo service nginx start
-
Deploy the Application:
- Create a deployment in CodeDeploy using the artifacts from S3.
- Verify the deployment by accessing the EC2 instance's public IP.
-
Create a CodePipeline:
- Go to CodePipeline > Create Pipeline.
- Name it
my-direction-app-pipeline
. - Choose source provider
AWS CodeCommit
, build providerAWS CodeBuild
, and deploy providerAWS CodeDeploy
. - Configure each stage to use the appropriate services and branches.
-
Pipeline Execution Modes:
- Superseded: Newer executions overtake older ones.
- Queued: Executions occur sequentially.
- Parallel: Executions run simultaneously.
-
Start the Pipeline:
- Check the pipeline stages (Source, Build, Deploy) for successful execution.
- Ensure the web application is deployed and accessible.
We've successfully created a CI/CD pipeline for a static web application using AWS DevOps services. This pipeline automates the deployment process, ensuring consistent and reliable deployments.