AWS CodeDeploy

AWS CodeDeploy is a managed service that can be used to streamline your delivery process. CodeDeploy uses an agent installed on EC2 instances and on-premises servers to poll for software revisions available. This agent takes the control of the delivery process by pulling software artifacts from GitHub and Amazon S3 as requested from deployments.

CodeDeploy is also AWS Lambda compatible and is platform agnostic. It provides a series of lifecycle events called hooks when deploying new software. Examples of these hooks are the BeforeInstall and ValidateService. The BeforeInstall can take of installing all required dependencies before the cut over of the previous version and the ValidateService hook can perform some smoke testing after deployment.

To demonstrate the use of AWS CodeDeploy, we will create a web artifact that will consist of an index.html web page. You can download the index.html sample code from https://github.com/gabanox/Certified-Solution-Architect-Associate-Guide/blob/master/chapter22/index.html or create one by your own.

CodeDeploy will require the CodeDeploy service role to perform deployments. Navigate to IAM, Create role, and choose the CodeDeploy service using the CodeDeploy use case in the lower section of the screen:

The IAM Policy will be automatically added to the service role. Assign it a name, for example, CodeDeployRole and click on Create role, as shown in the following screenshot:

Provision a couple of EC2 instances and use the user data to bootstrap the CodeDeploy agent installation process by copy pasting the following script:

#!/bin/bash -x 
REGION=$(curl 169.254.169.254/latest/meta-data/placement/availability-zone/ | sed 's/[a-z]$//') 
yum update -y 
yum install ruby wget -y 
cd /home/ec2-user 
wget https://aws-codedeploy-$REGION.s3.amazonaws.com/latest/install 
chmod +x ./install 
./install auto 

We will deploy the code using a subset of EC2 instances. For this demo, we are using EC2 tags to deploy the software revision. Use the following tags for the new instances. Also make sure to specify an S3 role to gain access to the deployment S3 bucket that will be used as the software repository for the artifact.

Now we are ready to create our web app.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.25.41