Deployment Steps

You might also like

Download as odt, pdf, or txt
Download as odt, pdf, or txt
You are on page 1of 3

CI/CD in AWS

1. Login Aws -> CodePipeline


2. Create Pipeline -> New Service Role -> Check the Checkbox -> Default Location -> Next.
3. Add Source Stage -> Give the AWS Code Commit -> Aws CodePipeline
4. Add Build Stage -> Aws Codebuild -> Select Project ( Create Project )
5. Skip deploy stage -> Confirm.

Create a buildspec.yml in the git and push it.

# Do not change version. This is the version of aws buildspec, not the version of your buldspec file.
version: 0.2

phases:
install:
commands:
pre_build:
commands:
- npm install
build:
commands:
post_build:
commands:
# Include only the files required for your application to run.
# Do not use recursively include artifacts from node_modules directory as it will
include unnecessary packages
# used only for building and testing.
# ExpressJS apps will need other artifact directories included (bin/*, public/*,
routes/*, views/* etc).
artifacts:
files:
- app.js
- index.html
- package.json
1. Create IAM Role -> EC2 -> AmazonEC2RoleForAWSCodeDeploy -> Create role with the
desired role name.
2. Create EC2 -> deploy the following.

sudo yum install -y httpd


sudo yum install -y git

sudo yum install -y ruby

sudo yum install -y wget

cd /home/ec2-user

wget https://bucket-name.s3.amazonaws.com/latest/install

chmod +x ./install

sudo ./install auto

3. https://docs.aws.amazon.com/codedeploy/latest/userguide/codedeploy-agent-operations-
install-ubuntu.html
4. Bucket-name is the name of the aws region. (aws-codedeploy-ap-south-1)
5. Install and Configure HTTP Server

<VirtualHost *:80>
6. ProxyPreserveHost On

ProxyPass / http://127.0.0.1:5000/
Redirect
ProxyPassReverse / http://127.0.0.1:5000/

ErrorLog ${APACHE_LOG_DIR}helloapp-error.log

CustomLog ${APACHE_LOG_DIR}helloapp-access.log common

</VirtualHost>
6. Auto scaling group for the created ec2 instance.

1. Create IAM Role -> AWSCodeDeployRole


2. CodeDeploy -> Create Application -> Ec2- on premisis
3. Create Deployment Group -> “Service Role” the IAM role -> Select the autoscaling group
4. Go to code pipeline -> Edit -> Add Stage
5. Aws deploy (Action provider) -> BuildArtifact -> Application Name -> Autoscalegroup
6. Create appspec.yml
7. Create installApp.sh
8. Add these files in the buildspec.yml

IAM ROLES:

1. Code commit Role.


2. Ec2 code deploy Instance Role.

AMI:
1. Create a server, install the requirements, let’s encrypt, ruby,nginx,install the code deploy and
start the deployment service.

• sudo apt install curl


• curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
• sudo apt-get install nodejs
• sudo apt install nginx
• sudo ufw enable
• sudo apt install ruby-full
• sudo wget https://aws-codedeploy-ap-south-1.s3.ap-south-1.amazonaws.com/latest/install
• sudo chmod +x ./install
• sudo ./install auto
• npm install pm2@latest -g
• sudo add-apt-repository ppa:certbot/certbot
• sudo apt install python-certbot-nginx
• -

2. Create ami of this server.


3. Set up launch config ( role ec2codedeploy ) and then auto-scaling.
4. Network load balancing.

You might also like