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
 
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
 
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
 
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

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 

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