Code Deploy and Code Pipeline
Code Deploy and Code Pipeline
Code Deploy and Code Pipeline
AWS CodePipeline is a continuous delivery service that enables you to model, visualize, and
automate the steps required to release your software. ... AWS CodePipeline then builds, tests, and
deploys your application according to the defined workflow every time there is a code change
CODE DEPLOY:
AWS CodeDeploy is a service that automates code deployments to Elastic Compute Cloud (EC2) and
on-premises servers. Accelerating how fast a developer can release code allows him to release new
features for an application faster and avoid deployment errors in complex applications.
Application: A CodeDeploy application can be defined from AWS CodeDeploy web console.
Appspec file: This contains the instruction to CodeDeploy, like copying of files, executing the scripts etc
during the code deployment process. It is present in the root directory of unzipped code with name
appspec.yml.
Deployment Group: Represent set of machines of Lambda function where code has to be deployed.
Setup in Brief:
I have used two EC2 instance of AMZ2 Linux. First one is the web server we will be configuring, also called
CodeDeploy agent. Second EC2 machine is supposed to use by developer where the codes are
programmed. The names of the resources in the experiment are arbitrary and may name the resources
your own.
1. Create IAM Roles for EC2-S3-CodeDeploy access.
2. Create IAM user account for developer
3. Install and prepare the CodeDeploy agent on webserver.
4. Create the code from Developer machine
5. Create Codedeploy Application and Push the code to S3 bucket from Developer machine
6. Create Deployment Group to include web server
7. Create Deployment to push the code to the Webserver
8. Test the website configuration
SERVICES REQUIRED: EC2,S3,CD,CP,CW,IAM,SNS
Step 1: Create IAM Roles for EC2-S3-CodeDeploy access:
a) s3 to ec2 full access: s3-ec2-full
select IAM service
goto Roles: select EC2 and click next Permissions
Create Amazon Linux EC2 Server with t2.micro instance type … open all tcp.
# wget https://aws-codedeploy-us-east-1.s3.amazonaws.com/latest/install
# chmod +x install
#./install auto
# service codedeploy-agent status
wget https://aws-codedeploy-us-east-1.s3.amazonaws.com/latest/install
download install script to install the code deploy agent
Chmod +x install
version: 0.0
os: linux
files:
- source: /index.html
destination: /var/www/html/
hooks:
BeforeInstall:
- location: scripts/httpd_install.sh
timeout: 300
runas: root
- location: scripts/httpd_start.sh
timeout: 300
runas: root
ApplicationStop:
- location: scripts/httpd_stop.sh
timeout: 300
runas: root
mkdir scripts
cd scripts
vi httpd_install.sh
vi httpd_start.sh
vi httpd_stop.sh
Step 5: Create Codedeploy Application and Push the code to S3 bucket from
Developer machine
a) Create bucket name called aws24092021 – make it public policy
Check and confirm whether the sample application been created successful created in the aws console:
b- Select sampleapp and click Create Deployment Group from Deployment Groups tab.
c- Enter the values like below and leave the other parameters default
RESOLUTION:
ENABLE BUCKET VERSIONING AND SAVE
CLICK RETRY….
NEW SOURCE CODE HAS BEEN SUCCESSFULLY TRIGGERED FROM S3 BY CODE PIPELINE AND
DEPLOYMENT NEW VERSION INTO WEBSERVER
VERIFY THE SAME BY HITTING THE PUBLIC IP OF THE WEBSER MACHINE IN THE BROWSER
AND CHECK
ENABLE THE NOTIFICATION SERVICE: ALERTING TO THE USER IN CASE IF THE
DEPLOYMENT SUCCEED, FAILED, START ETC
SUBSCRIPTION CONFIRMED
CREATE SUBSCRIPTION
EMAIL NOTIFICATION:
SMS NOTIFICATION:
DEMOLISH:
1. DELETE INSTANCES
2. DELETE CODE DEPLOY
3. DELETE CODE PIPELINE
4. DELETE BUCKET AND OBJECT
5. DELETE SNS TOPIC AND SUBSCRIPTIONS
6. DELETE IAM ROLES AND USERS