AWS CodeDeploy

Hands-On

Demo

In this demo, we will:

  1. Create IAM roles for CodeDeploy and EC2 instances
  2. Launch and configure EC2 instances with CodeDeploy agent
  3. Create a CodeDeploy application and deployment group
  4. Prepare a sample web application with deployment configuration
  5. Create and upload application revision to S3
  6. Execute a deployment using CodeDeploy
  7. Test the deployed application and monitor deployment status
  8. Clean up resources

Agenda

Visual Representation

CodeDeploy

Create CodeDeploy IAM Role

Add permissions

Name, review, and create

CodeDeployServiceRole

Step 1: Select trusted entities

Step 2: Add permissions

CodeDeployServiceRole

Create EC2 IAM Instance Profile Role

Add permissions

AmazonEC2RoleforAWSCodeDeploy
AmazonS3ReadOnlyAccess

Add permissions

Name, review, and create

EC2CodeDeployRole

Step 1: Select trusted entities

Create role

EC2CodeDeployRole

EC2 - Launch Instance 

CodeDeploy-Demo-Instance-1

Launch an instance

Environment
Demo

Instance type

codedeploy-key-pair

Key pair (login)

Network settings

Configure storage

Advanced details

#!/bin/bash
yum update -y
yum install -y ruby wget httpd
cd /home/ec2-user
wget https://aws-codedeploy-us-east-1.s3.us-east-1.amazonaws.com/latest/install
chmod +x ./install
./install auto
systemctl start codedeploy-agent
systemctl enable codedeploy-agent
systemctl start httpd
systemctl enable httpd

User data

Launch 2nd Instance 

CodeDeploy-Demo-Instance-2
Environment
Demo

Instance type

Key pair (login)

Network settings

Configure storage

Advanced details

#!/bin/bash
yum update -y
yum install -y ruby wget httpd
cd /home/ec2-user
wget https://aws-codedeploy-us-east-1.s3.us-east-1.amazonaws.com/latest/install
chmod +x ./install
./install auto
systemctl start codedeploy-agent
systemctl enable codedeploy-agent
systemctl start httpd
systemctl enable httpd

Instances (2)

CodeDeploy - Create application 

MyWebApp

Create application

Create application

Create deployment group

MyWebApp-DeploymentGroup

Deployment type

Choose this

Environment configuration

Environment
Demo

Deployment settings

Load balancer

Triggers

Rollbacks

Deployment group tags

Sample Application

chmod +X scripts/*.sh

Create S3 bucket

codedeploy-demo-bucket-012931
cd ..
zip -r mywebapp-v1.zip my-web-app/

Upload to S3 

Upload succeeded

Create Deployment

S3 Location

s3://codedeploy-demo-bucket-012931/mywebapp-v1.zip

Deployment description

Additional deployment behaviour settings

Deployment group overrides

Roll back configuration overrides

Revision details

Test

http://3.82.146.251
http://44.202.11.142

Deploy 2nd Version

#ffe0f0
zip -r mywebapp-v2.zip my-web-app/

Upload 2nd Version

codedeploy-demo-bucket-012931

Create 2nd  deployment

s3://codedeploy-demo-bucket-012931/mywebapp-v2.zip

Revision details

http://3.82.146.251
http://44.202.11.142

Clean Up

Delete application

Terminate EC2 Instances 

Terminate (delete) instances

Empty S3 Bucket 

permanently delete

Empty bucket

Delete S3 Bucket 

Delete bucket

Delete CodeDeployServiceRole Role

CodeDeployServiceRole

Delete EC2CodeDeployRole

EC2CodeDeployRole

Delete security groups

Delete security groups

Delete Key pair 

🙏

Thanks

for

Watching

AWS CodeDeploy - Hands-On Demo

By Deepak Dubey

AWS CodeDeploy - Hands-On Demo

AWS CodeDeploy - Hands-On Demo

  • 5