SlideShare une entreprise Scribd logo
1  sur  26
Integrate AWS CodeDeploy with Git
and Deploy a Revision
- Ishant Kumar
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
Reference : http://docs.aws.amazon.com/codedeploy/latest/userguide/welcome.html
Benefits :
The benefit of Automated Deployment
downtime can be minimized.
Control your App Centralized
Easy to use and adopt
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”: “*” } ] }
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
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”: “*” }
]
}
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”
}
] }
Directory Structure :
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….
Contents of file appspec.yml (continued …..)
– location: scripts/install_dependencies
timeout: 300
runas: root
– location: scripts/start_server
timeout: 300
runas: root
ApplicationStop:
– location: scripts/stop_server
timeout: 300
runas: root
contents of file install_dependencies
#!/bin/bash
yum install -y nginx
rm -f /usr/share/nginx/html/index.html
Contents of file start_server
#!/bin/bash
service nginx start
Contents of file stop_server
#!/bin/bash
isExistApp = `pgrep nginx` if [[ -n $isExistApp ]];
then
service nginx stop
fi
Now lets start
from here .
Step 1 : SignIn to
AWS console
and select AWS
CodeDeploy.
Step 2 : Click on get started Now.
Step 3 : Select custom Deployment and click on skip walk through.
Step 4: Create new Application by passing Application Name and
Deployment Group Name.
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).
Step 6 : Select service role ARN so that Code Deploy can access EC2.
Role should have updated trust relationship. Click on Create
Application.
Step 7 : Click on DemoDeploymentGroup Drop Down Arrow and click
on Deploy New Revision.
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.
Step 8: (continued ….)
Step 9 : Select Deployment id to check Application status.
Step 10 : You will see status succeeded if the deployment is successful.
Click on events if you want to check the events performed.
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.
Thanks
Looking Forward for your interest in DevOpsJourney.com
http://devopsjourney.com
Email us: mail@devopsjourney.com

Contenu connexe

Tendances

AWS CodeDeploy
AWS CodeDeployAWS CodeDeploy
AWS CodeDeploy
TO THE NEW | Technology
 
如何無痛上雲端? 以Elastic Beanstalk Java Container為例
如何無痛上雲端? 以Elastic Beanstalk Java Container為例如何無痛上雲端? 以Elastic Beanstalk Java Container為例
如何無痛上雲端? 以Elastic Beanstalk Java Container為例
Yuen-Kuei Hsueh
 

Tendances (20)

DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsDevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
 
AWS CodeDeploy: Manage Deployment Complexity
AWS CodeDeploy: Manage Deployment ComplexityAWS CodeDeploy: Manage Deployment Complexity
AWS CodeDeploy: Manage Deployment Complexity
 
Releasing Software Quickly and Reliably With AWS CodePipeline by Mark Mansour...
Releasing Software Quickly and Reliably With AWS CodePipeline by Mark Mansour...Releasing Software Quickly and Reliably With AWS CodePipeline by Mark Mansour...
Releasing Software Quickly and Reliably With AWS CodePipeline by Mark Mansour...
 
Automate Software Deployments on EC2 with AWS CodeDeploy
Automate Software Deployments on EC2 with AWS CodeDeployAutomate Software Deployments on EC2 with AWS CodeDeploy
Automate Software Deployments on EC2 with AWS CodeDeploy
 
AWS OpsWorks for Chef Automate
AWS OpsWorks for Chef AutomateAWS OpsWorks for Chef Automate
AWS OpsWorks for Chef Automate
 
(DVO305) Turbocharge YContinuous Deployment Pipeline with Containers
(DVO305) Turbocharge YContinuous Deployment Pipeline with Containers(DVO305) Turbocharge YContinuous Deployment Pipeline with Containers
(DVO305) Turbocharge YContinuous Deployment Pipeline with Containers
 
Automating Software Deployments with AWS CodeDeploy by Matthew Trescot, Manag...
Automating Software Deployments with AWS CodeDeploy by Matthew Trescot, Manag...Automating Software Deployments with AWS CodeDeploy by Matthew Trescot, Manag...
Automating Software Deployments with AWS CodeDeploy by Matthew Trescot, Manag...
 
Agile Deployment using Git and AWS Elastic Beanstalk
Agile Deployment using Git and AWS Elastic BeanstalkAgile Deployment using Git and AWS Elastic Beanstalk
Agile Deployment using Git and AWS Elastic Beanstalk
 
AWS CodeDeploy
AWS CodeDeployAWS CodeDeploy
AWS CodeDeploy
 
AWS July Webinar Series: Introducing AWS OpsWorks for Windows Server
AWS July Webinar Series: Introducing AWS OpsWorks for Windows ServerAWS July Webinar Series: Introducing AWS OpsWorks for Windows Server
AWS July Webinar Series: Introducing AWS OpsWorks for Windows Server
 
Deploy, Manage, and Scale your Apps with AWS Elastic Beanstalk
Deploy, Manage, and Scale your Apps with AWS Elastic BeanstalkDeploy, Manage, and Scale your Apps with AWS Elastic Beanstalk
Deploy, Manage, and Scale your Apps with AWS Elastic Beanstalk
 
AWS CodeCommit, CodeDeploy & CodePipeline
AWS CodeCommit, CodeDeploy & CodePipelineAWS CodeCommit, CodeDeploy & CodePipeline
AWS CodeCommit, CodeDeploy & CodePipeline
 
Hands-on with AWS IoT
Hands-on with AWS IoTHands-on with AWS IoT
Hands-on with AWS IoT
 
AWS January 2016 Webinar Series - Introduction to Deploying Applications on AWS
AWS January 2016 Webinar Series - Introduction to Deploying Applications on AWSAWS January 2016 Webinar Series - Introduction to Deploying Applications on AWS
AWS January 2016 Webinar Series - Introduction to Deploying Applications on AWS
 
AWS Code Services
AWS Code ServicesAWS Code Services
AWS Code Services
 
Introducing AWS Elastic Beanstalk
Introducing AWS Elastic BeanstalkIntroducing AWS Elastic Beanstalk
Introducing AWS Elastic Beanstalk
 
如何無痛上雲端? 以Elastic Beanstalk Java Container為例
如何無痛上雲端? 以Elastic Beanstalk Java Container為例如何無痛上雲端? 以Elastic Beanstalk Java Container為例
如何無痛上雲端? 以Elastic Beanstalk Java Container為例
 
Continuous Delivery to Amazon EC2 Container Service
Continuous Delivery to Amazon EC2 Container ServiceContinuous Delivery to Amazon EC2 Container Service
Continuous Delivery to Amazon EC2 Container Service
 
Introduction to AWS CodeStar: Quickly develop, build, and deploy applications...
Introduction to AWS CodeStar: Quickly develop, build, and deploy applications...Introduction to AWS CodeStar: Quickly develop, build, and deploy applications...
Introduction to AWS CodeStar: Quickly develop, build, and deploy applications...
 
DevOps at Amazon: A Look at Our Tools and Processes by Matthew Trescot, Manag...
DevOps at Amazon: A Look at Our Tools and Processes by Matthew Trescot, Manag...DevOps at Amazon: A Look at Our Tools and Processes by Matthew Trescot, Manag...
DevOps at Amazon: A Look at Our Tools and Processes by Matthew Trescot, Manag...
 

Similaire à Integrate AWS CodeDeploy With Git And Deploy A Revision

Track 4 Session 4_ MAD02 MAD 04 如何藉由 CICD 流程管理容器化和無伺服器應用
Track 4 Session 4_ MAD02 MAD 04 如何藉由 CICD 流程管理容器化和無伺服器應用Track 4 Session 4_ MAD02 MAD 04 如何藉由 CICD 流程管理容器化和無伺服器應用
Track 4 Session 4_ MAD02 MAD 04 如何藉由 CICD 流程管理容器化和無伺服器應用
Amazon Web Services
 
A Tale of Two Pizzas: Accelerating Software Delivery with Developer Tools - D...
A Tale of Two Pizzas: Accelerating Software Delivery with Developer Tools - D...A Tale of Two Pizzas: Accelerating Software Delivery with Developer Tools - D...
A Tale of Two Pizzas: Accelerating Software Delivery with Developer Tools - D...
Amazon Web Services
 

Similaire à Integrate AWS CodeDeploy With Git And Deploy A Revision (20)

AWS CodeDeploy
AWS CodeDeploy AWS CodeDeploy
AWS CodeDeploy
 
Continuous Integration e Delivery per (r)innovare lo sviluppo software e la g...
Continuous Integration e Delivery per (r)innovare lo sviluppo software e la g...Continuous Integration e Delivery per (r)innovare lo sviluppo software e la g...
Continuous Integration e Delivery per (r)innovare lo sviluppo software e la g...
 
AWS Atlanta meetup Build Tools - Code Commit, Code Build, Code Deploy
AWS Atlanta meetup Build Tools - Code Commit, Code Build, Code DeployAWS Atlanta meetup Build Tools - Code Commit, Code Build, Code Deploy
AWS Atlanta meetup Build Tools - Code Commit, Code Build, Code Deploy
 
CI&CD on AWS - Meetup Roma Oct 2016
CI&CD on AWS - Meetup Roma Oct 2016CI&CD on AWS - Meetup Roma Oct 2016
CI&CD on AWS - Meetup Roma Oct 2016
 
Simple Odoo ERP auto scaling on AWS
Simple Odoo ERP auto scaling on AWSSimple Odoo ERP auto scaling on AWS
Simple Odoo ERP auto scaling on AWS
 
What Is AWS Elastic Kubernetes Service
 What Is AWS Elastic Kubernetes Service What Is AWS Elastic Kubernetes Service
What Is AWS Elastic Kubernetes Service
 
McrUmbMeetup 22 May 14: Umbraco and Amazon
McrUmbMeetup 22 May 14: Umbraco and AmazonMcrUmbMeetup 22 May 14: Umbraco and Amazon
McrUmbMeetup 22 May 14: Umbraco and Amazon
 
Mateusz Zając - Continuous Integration i jej skalowalność w oparciu o TeamCit...
Mateusz Zając - Continuous Integration i jej skalowalność w oparciu o TeamCit...Mateusz Zając - Continuous Integration i jej skalowalność w oparciu o TeamCit...
Mateusz Zając - Continuous Integration i jej skalowalność w oparciu o TeamCit...
 
AWS DevOps Essentials: An Introductory Workshop on CI/CD Best Practices (DEV3...
AWS DevOps Essentials: An Introductory Workshop on CI/CD Best Practices (DEV3...AWS DevOps Essentials: An Introductory Workshop on CI/CD Best Practices (DEV3...
AWS DevOps Essentials: An Introductory Workshop on CI/CD Best Practices (DEV3...
 
Track 4 Session 4_ MAD02 MAD 04 如何藉由 CICD 流程管理容器化和無伺服器應用
Track 4 Session 4_ MAD02 MAD 04 如何藉由 CICD 流程管理容器化和無伺服器應用Track 4 Session 4_ MAD02 MAD 04 如何藉由 CICD 流程管理容器化和無伺服器應用
Track 4 Session 4_ MAD02 MAD 04 如何藉由 CICD 流程管理容器化和無伺服器應用
 
Automating Software Deployments with AWS CodeDeploy
Automating Software Deployments with AWS CodeDeployAutomating Software Deployments with AWS CodeDeploy
Automating Software Deployments with AWS CodeDeploy
 
DevOps Tooling - Pop-up Loft TLV 2017
DevOps Tooling - Pop-up Loft TLV 2017DevOps Tooling - Pop-up Loft TLV 2017
DevOps Tooling - Pop-up Loft TLV 2017
 
AWS Serverless Workshop
AWS Serverless WorkshopAWS Serverless Workshop
AWS Serverless Workshop
 
CON319_Interstella GTC CICD for Containers on AWS
CON319_Interstella GTC CICD for Containers on AWSCON319_Interstella GTC CICD for Containers on AWS
CON319_Interstella GTC CICD for Containers on AWS
 
Interstella 8888: CICD for Containers on AWS - CON319 - re:Invent 2017
Interstella 8888: CICD for Containers on AWS - CON319 - re:Invent 2017Interstella 8888: CICD for Containers on AWS - CON319 - re:Invent 2017
Interstella 8888: CICD for Containers on AWS - CON319 - re:Invent 2017
 
A Tale of Two Pizzas: Accelerating Software Delivery with Developer Tools - D...
A Tale of Two Pizzas: Accelerating Software Delivery with Developer Tools - D...A Tale of Two Pizzas: Accelerating Software Delivery with Developer Tools - D...
A Tale of Two Pizzas: Accelerating Software Delivery with Developer Tools - D...
 
Remove Undifferentiated Heavy Lifting from Jenkins (DEV201-R1) - AWS re:Inven...
Remove Undifferentiated Heavy Lifting from Jenkins (DEV201-R1) - AWS re:Inven...Remove Undifferentiated Heavy Lifting from Jenkins (DEV201-R1) - AWS re:Inven...
Remove Undifferentiated Heavy Lifting from Jenkins (DEV201-R1) - AWS re:Inven...
 
Deep Dive on Serverless Stack
Deep Dive on Serverless StackDeep Dive on Serverless Stack
Deep Dive on Serverless Stack
 
Different methods for aws integration with jenkins
Different methods for aws integration with jenkinsDifferent methods for aws integration with jenkins
Different methods for aws integration with jenkins
 
Day 2 - Amazon EC2 Masterclass - Getting the most from Amazon EC2
Day 2 - Amazon EC2 Masterclass - Getting the most from Amazon EC2Day 2 - Amazon EC2 Masterclass - Getting the most from Amazon EC2
Day 2 - Amazon EC2 Masterclass - Getting the most from Amazon EC2
 

Plus de devopsjourney (6)

5 Important Points To Remember If You Want To Reduce AWS EC2 Cost
5 Important Points To Remember If You Want To Reduce AWS EC2 Cost5 Important Points To Remember If You Want To Reduce AWS EC2 Cost
5 Important Points To Remember If You Want To Reduce AWS EC2 Cost
 
Understand AWS OpsWorks - A DevOps Tool from AWS
Understand AWS OpsWorks - A DevOps Tool from AWSUnderstand AWS OpsWorks - A DevOps Tool from AWS
Understand AWS OpsWorks - A DevOps Tool from AWS
 
Integrate Jenkins with S3
Integrate Jenkins with S3Integrate Jenkins with S3
Integrate Jenkins with S3
 
How to Write Chef Cookbook
How to Write Chef CookbookHow to Write Chef Cookbook
How to Write Chef Cookbook
 
Understand Chef
Understand ChefUnderstand Chef
Understand Chef
 
Top 10 DevOps Areas Need To Focus
Top 10 DevOps Areas Need To FocusTop 10 DevOps Areas Need To Focus
Top 10 DevOps Areas Need To Focus
 

Dernier

Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
panagenda
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
Muhammad Subhan
 

Dernier (20)

Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overview
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdf
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 

Integrate AWS CodeDeploy With Git And Deploy A Revision

  • 1. Integrate AWS CodeDeploy with Git and Deploy a Revision - Ishant Kumar
  • 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….
  • 11. Contents of file appspec.yml (continued …..) – location: scripts/install_dependencies timeout: 300 runas: root – location: scripts/start_server timeout: 300 runas: root ApplicationStop: – location: scripts/stop_server timeout: 300 runas: root
  • 12. contents of file install_dependencies #!/bin/bash yum install -y nginx rm -f /usr/share/nginx/html/index.html Contents of file start_server #!/bin/bash service nginx start
  • 13. Contents of file stop_server #!/bin/bash isExistApp = `pgrep nginx` if [[ -n $isExistApp ]]; then service nginx stop fi
  • 14. Now lets start from here . Step 1 : SignIn to AWS console and select AWS CodeDeploy.
  • 15. Step 2 : Click on get started Now.
  • 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