2. In these slides of DevOps Journey, we will demonstrate how to
integrate Git with AWS CodeDeploy Service.
What is AWS CodeDeploy?
AWS CodeDeploy is an AWS service that coordinates application
deployments to instances. Instances are groups of one or more
Amazon EC2 instances or on-premises instances or both. (On-premises
instances are physical devices that are not Amazon EC2 instances.)
Source : http://docs.aws.amazon.com/codedeploy/latest/userguide/welcome.html
4. Benefits :
The benefit of Automated Deployment
downtime can be minimized.
Control your App Centralized
Easy to use and adopt
5. Prerequisite :
Create one EC2 instance with Amazon Linux AMI.
Instance should be provisioned with below IAM Role as
Instance need to download CodeDeploy Agent from S3 bucket.
{ “Version”: “2012-10-17″,
“Statement”:
[ { “Action”: [ “s3:Get*”, “s3:List*” ],
“Effect”: “Allow”,
“Resource”: “*” } ] }
6. Execute the below commands to configure and install
codedeploy agent on the instance.
sudo yum -y update
sudo yum -y install ruby
sudo yum -y install
aws-cli cd /home/ec2-user
aws s3 cp s3://aws-codedeploy-us-east-1/latest/install . –region us-east-1
chmod +x ./install
sudo ./install auto
7. Now create one more Service role for CodeDeploy Service so that service should
have EC2 Access.
{ “Version”: “yyyy-mm-dd”,
“Statement”:
[
{ “Action”: [ “autoscaling:PutLifecycleHook”, “autoscaling:DeleteLifecycleHook”,
“autoscaling:RecordLifecycleActionHeartbeat”, “autoscaling:CompleteLifecycleAction”,
“autoscaling:DescribeAutoscalingGroups”, “autoscaling:PutInstanceInStandby”,
“autoscaling:PutInstanceInService”, “ec2:Describe*” ],
“Effect”: “Allow”,
“Resource”: “*” }
]
}
8. Replace the entire contents of the Policy Document box with
the following policy, and then click Update Trust Policy:
{ “Version”: “2012-10-17″,
“Statement”:
[
{
“Sid”: “”, “Effect”: “Allow”, “Principal”:
{
“Service”: [ “codedeploy.us-east-1.amazonaws.com”,]
},
“Action”: “sts:AssumeRole”
}
] }
10. To Know How to setup Git on AWS EC2 , You can look our
uploaded slide Setting up Git on AWS EC2 .
Contents of file appspec.yml
version: 0.0
os: linux
files:
– source: /index.html
destination: /usr/share/nginx/html/
hooks:
BeforeInstall:
Continue….
16. Step 3 : Select custom Deployment and click on skip walk through.
17. Step 4: Create new Application by passing Application Name and
Deployment Group Name.
18. Step 5 : Select instance(s) on which you want to deploy the code.
(Instance(s) should have valid instance profile and code deploy agent
installed).
19. Step 6 : Select service role ARN so that Code Deploy can access EC2.
Role should have updated trust relationship. Click on Create
Application.
20. Step 7 : Click on DemoDeploymentGroup Drop Down Arrow and click
on Deploy New Revision.
21. Step 8: Select Your Application , Deployment Group and Revision Type.
For Github , select “My Application is stored in Github” , and connect with
Github by providing Github’s Username and password. Enter your user-
name/Repository-name, comimit id of your latest code checkin and Deploy the
Application.
23. Step 9 : Select Deployment id to check Application status.
24. Step 10 : You will see status succeeded if the deployment is successful.
Click on events if you want to check the events performed.
25. Step 11 : Try hitting public ip of Instance. You will see below page.
So this is how we can integrate AWS CodeDeploy with GitHub and can
deploy the code with commit Id. If you want to deploy one more
revision with updated code, pass the updated commit Id and Deploy
the code.
26. Thanks
Looking Forward for your interest in DevOpsJourney.com
http://devopsjourney.com
Email us: mail@devopsjourney.com