September 22, 2018

LAB 4 - AWS CI CD - Setup deploy project using AWS CodeDeploy

This Lab has the step by step instructions to create EC2 instance(s) to be used by code deploy, create IAM Service Role to handle code deploy, create CodeDeploy application and deployment group in AWS CodeDeploy and commit the pre-developed sample Java Application.

Ensure to complete LAB 1 through LAB 3 including pre-requisite as stated in AWS Developer Tools CI CD Lab blog.

Login to AWS Console as `codedeploy_user` and perform the following

Create EC2 Instance:

Create Security Group: 

Go to EC2 -> Create Security -> Create Security group as sg_codedeploy with the following inbound rules

Create IAM Instance Profile Role:

Go to IAM -> Roles to create an Instance profile role named codedeploy_InstanceProfile_role with the following permissions
  • CloudWatchFullAccess
  • AmazonS3ReadOnlyAccess

Create Code Deploy Service Role:

Go to IAM -> Roles to create a Service Role with the policy AWSCodeDeployRole attached.

Create EC2 instance(s):

Go to EC2 -> Launch Instances to create 1 or more t2.micro EC2 instance based out of Amazon Linux AMI along with the above Security Group, IAM Instance Profile Role and Add Tag as codedeploy_demo_EC2
SSH to the instance & install Code Deploy Agent as follows
$ ssh -i <path to Keyfile/keyfilename.pem> ec2-user@<public ip>
          $ yum update -y
          $ yum install wget
          $ cd /home/ec2-user
          $ wget https://aws-codedeploy-${AWS::Region}.s3.amazonaws.com/latest/install
         $ chmod +X ./install
         $ ./install auto

         
sudo service codedeploy-agent status
         $ sudo service codedeploy-agent start

Create, Configure & Execute CodeDeploy Project:

Go to AWS CodeDeploy dashboard to create a code deploy application and deployment group








Here is the closer look of appspec.yml used in this example.

Quick Reference Links:


Redeploy and Roll Back a Deployment with AWS CodeDeploy


No comments:

Post a Comment