SlideShare a Scribd company logo
AWS CodeDeploy
By Anton Babenko, May 2016
Hi!
Anton Babenko
I enjoy AWS, DevOps and web-development.
I am AWS Certified Solution Architect, SysOps and DevOps.
I work as DevOps engineer at Your.MD.
I am one of organizers of AWS User Group Norway meetups
( Next meetup - “Big data experience at Schibsted”, 30th of May, 17:30 at MESH )
github.com/antonbabenko linkedin.com/in/antonbabenko
anton@antonbabenko.com
What is AWS CodeDeploy?
Fully managed service which allows deployment to Amazon EC2 and on-premise instances
Requires no modifications to existing code and is technology agnostic
Can deploy from Amazon S3 buckets and Github repos
Free
Getting started
Install codedeploy agent
Prepare your application (add appspec.yml)
Create archive and register application revision
Create archive, upload it to S3 and register application revision:
aws deploy push
Register application revision (can be combined with ghr):
aws deploy register-application-revision
Configure target environment (“deployment group”)
Deploy
Deploy application revision (myapp-v1.0.zip) to deployment group (myapp-prod) according to deployment
configuration (CodeDeployDefault.OneAtATime):
aws deploy create-deployment 
--application-name myapp 
--deployment-config-name CodeDeployDefault.OneAtATime 
--deployment-group-name myapp-prod 
--description "My app v1.0 deployment to production" 
--s3-location bucket=myapp-archives,bundleType=zip,key=myapp-v1.0.zip
Execution flow
appspec.yml
version: 0.0
os: linux
files:
- source: Config/config.txt
destination: webapps/Config
- source: source
destination: /webapps/myApp
# permissions: # skipped on this example
hooks:
ApplicationStop:
- location: codedeploy/playbooks/application_stop.yml
BeforeInstall:
- location: codedeploy/playbooks/before_install.yml
- location: Scripts/UnzipDataBundle.sh
AfterInstall:
- location: codedeploy/playbooks/after_install.yml
ApplicationStart:
- location: codedeploy/playbooks/application_start.yml
timeout: 3600
ValidateService:
- location: Scripts/MonitorService.sh
timeout: 3600
runas: codedeployuser
codedeploy/playbooks/application_stop.yml
#!/usr/bin/env ansible-playbook
---
- hosts: localhost
gather_facts: false
become: true
tasks:
- name: Stop supervisor service
ignore_errors: yes
supervisorctl:
name: "search"
state: stopped
Deployment configuration
One at a time
Half at a time
All at once
Custom
Deployment group
Options:
One per environment (development-site, staging-site, production-site)
Blue-green fashion:
production-site-blue + application revision v1.0
production-site-green + application revision v1.1
Integrations
Github webhooks
S3 + AWS Lambda
CircleCI, CodeShip, Jenkins, etc
AWS
Auto-scaling
ELB
SNS
Cloudwatch
Cloudtrail
Terraform
Considerations
S3 bucket and CodeDeploy application should be in the same AWS region
S3 cross-region replication does not work for private files
Solution: Register application revision for each region/bucket individually
Take care of created files not managed by CodeDeploy yourself
Solution: Use BeforeInstall hook
No control of what revision to deploy during ASG scaling activity
No straightforward solutions I know, only hacks (wrapper-application, triggers to SNS)
Watch out for infinite EC2 restarts during ASG scaling activity
Solution: Use ValidateService hook wisely
Hint: Test deployments on both running and newly created instances
Thank you!
Questions ?

More Related Content

PDF
Continuous delivery in AWS
PPTX
Designing for elasticity on AWS - 9.11.2015
PPTX
Managing AWS infrastructure using CloudFormation
PPTX
AWS elastic beanstalk
PDF
A real-life account of moving 100% to a public cloud
PDF
Amazon ECS (December 2015)
PDF
Hands-on with AWS IoT
PPTX
Moving Viadeo to AWS (2015)
Continuous delivery in AWS
Designing for elasticity on AWS - 9.11.2015
Managing AWS infrastructure using CloudFormation
AWS elastic beanstalk
A real-life account of moving 100% to a public cloud
Amazon ECS (December 2015)
Hands-on with AWS IoT
Moving Viadeo to AWS (2015)

What's hot (18)

PDF
Using Amazon CloudWatch Events, AWS Lambda and Spark Streaming to Process EC...
PDF
Ansible Introduction
PPTX
End-to-end CI/CD deployments of containerized applications using AWS services
PDF
AWS CloudFormation (February 2016)
PPT
C# Async on iOS and Android - Craig Dunn, Developer Evangelist at Xamarin
PPTX
goployer, 코드 기반의 배포 도구 - 송주영 (beNX) :: AWS Community Day 2020
PPTX
Packer, Terraform, Ansible avec Azure
PPTX
Multi host container networking
PDF
[Jun AWS 201] Elastic Beanstalk for Startups
PDF
Building a Serverless Pipeline
PPTX
Where is my scalable API?
PPTX
Build and deployment with Jenkins and Code Deploy on AWS
PDF
2016 05-cloudsoft-amp-and-brooklyn-new
PDF
초기 스타트업의 AWS - 김지훈(투어라이브) :: AWS Community Day Online 2020
PDF
CI/CD Using Ansible and Jenkins for Infrastructure
PDF
Building serverless apps with Node.js
PDF
Meeyup aws-loadbalancing-28032015
PDF
Scaling your web app horizontally and vertically (ahmedabad amazon aws cloud...
Using Amazon CloudWatch Events, AWS Lambda and Spark Streaming to Process EC...
Ansible Introduction
End-to-end CI/CD deployments of containerized applications using AWS services
AWS CloudFormation (February 2016)
C# Async on iOS and Android - Craig Dunn, Developer Evangelist at Xamarin
goployer, 코드 기반의 배포 도구 - 송주영 (beNX) :: AWS Community Day 2020
Packer, Terraform, Ansible avec Azure
Multi host container networking
[Jun AWS 201] Elastic Beanstalk for Startups
Building a Serverless Pipeline
Where is my scalable API?
Build and deployment with Jenkins and Code Deploy on AWS
2016 05-cloudsoft-amp-and-brooklyn-new
초기 스타트업의 AWS - 김지훈(투어라이브) :: AWS Community Day Online 2020
CI/CD Using Ansible and Jenkins for Infrastructure
Building serverless apps with Node.js
Meeyup aws-loadbalancing-28032015
Scaling your web app horizontally and vertically (ahmedabad amazon aws cloud...
Ad

Similar to AWS CodeDeploy - basic intro (20)

PPTX
AWS CodeDeploy + Github
PDF
Continuous Deployment @ AWS Re:Invent
PDF
Hosting Your Own OTA Update Service
PDF
Parse cloud code
PDF
Kubernetes for the PHP developer
PDF
CI&CD on AWS - Meetup Roma Oct 2016
PDF
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
PDF
A 60-minute tour of AWS Compute (November 2016)
ODP
Capifony. Minsk PHP MeetUp #11
PDF
Cannibalising The Google App Engine
DOCX
Simple Odoo ERP auto scaling on AWS
PDF
Scale your PHP application with Elastic Beanstalk - CloudParty Genova
PPTX
Introduction to JIB and Google Cloud Run
PDF
Fargate 를 이용한 ECS with VPC 1부
PDF
NodeJS @ ACS
PDF
Containerizing your Security Operations Center
PDF
One-Man Ops
PDF
A DevOps guide to Kubernetes
PDF
Making Sense out of Amazon ECS
PDF
Dockerize your Symfony application - Symfony Live NYC 2014
AWS CodeDeploy + Github
Continuous Deployment @ AWS Re:Invent
Hosting Your Own OTA Update Service
Parse cloud code
Kubernetes for the PHP developer
CI&CD on AWS - Meetup Roma Oct 2016
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
A 60-minute tour of AWS Compute (November 2016)
Capifony. Minsk PHP MeetUp #11
Cannibalising The Google App Engine
Simple Odoo ERP auto scaling on AWS
Scale your PHP application with Elastic Beanstalk - CloudParty Genova
Introduction to JIB and Google Cloud Run
Fargate 를 이용한 ECS with VPC 1부
NodeJS @ ACS
Containerizing your Security Operations Center
One-Man Ops
A DevOps guide to Kubernetes
Making Sense out of Amazon ECS
Dockerize your Symfony application - Symfony Live NYC 2014
Ad

More from Anton Babenko (20)

PDF
Manage any AWS resources with Terraform 0.12 - April 2020
PDF
Terraform 0.12 + Terragrunt
PDF
Terraform Best Practices - DevOps Unicorns 2019
PDF
Terraform AWS modules and some best practices - September 2019
PDF
What you see is what you get for AWS infrastructure
PDF
Terraform AWS modules and some best-practices - May 2019
PDF
Terraform modules and some of best-practices - March 2019
PDF
What you see is what you get for AWS infrastructure
PDF
Gotchas using Terraform in a secure delivery pipeline
PDF
Описание инфраструктуры с Terraform на будущее
PDF
Preview of Terraform 0.12 + modules.tf - Kiev HUG meetup
PDF
Terraform modules and (some of) best practices
PDF
Terraform modules and (some of) best practices
PDF
Terraform modules and best-practices - September 2018
PDF
Building infrastructure as code using Terraform - DevOps Krakow
PDF
Terraform Q&A - HashiCorp User Group Oslo
PDF
"I’ve heard you know infrastructure"
PDF
Terraform in deployment pipeline
PPTX
"Continuously delivering infrastructure using Terraform and Packer" training ...
PDF
Tools exist for a reason
Manage any AWS resources with Terraform 0.12 - April 2020
Terraform 0.12 + Terragrunt
Terraform Best Practices - DevOps Unicorns 2019
Terraform AWS modules and some best practices - September 2019
What you see is what you get for AWS infrastructure
Terraform AWS modules and some best-practices - May 2019
Terraform modules and some of best-practices - March 2019
What you see is what you get for AWS infrastructure
Gotchas using Terraform in a secure delivery pipeline
Описание инфраструктуры с Terraform на будущее
Preview of Terraform 0.12 + modules.tf - Kiev HUG meetup
Terraform modules and (some of) best practices
Terraform modules and (some of) best practices
Terraform modules and best-practices - September 2018
Building infrastructure as code using Terraform - DevOps Krakow
Terraform Q&A - HashiCorp User Group Oslo
"I’ve heard you know infrastructure"
Terraform in deployment pipeline
"Continuously delivering infrastructure using Terraform and Packer" training ...
Tools exist for a reason

Recently uploaded (20)

PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Modernizing your data center with Dell and AMD
PDF
Transforming Manufacturing operations through Intelligent Integrations
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
PDF
Sensors and Actuators in IoT Systems using pdf
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
PDF
Advanced IT Governance
PDF
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Chapter 3 Spatial Domain Image Processing.pdf
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
20250228 LYD VKU AI Blended-Learning.pptx
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
NewMind AI Monthly Chronicles - July 2025
The Rise and Fall of 3GPP – Time for a Sabbatical?
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Modernizing your data center with Dell and AMD
Transforming Manufacturing operations through Intelligent Integrations
Spectral efficient network and resource selection model in 5G networks
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
Sensors and Actuators in IoT Systems using pdf
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
Advanced IT Governance
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf

AWS CodeDeploy - basic intro

  • 1. AWS CodeDeploy By Anton Babenko, May 2016
  • 2. Hi! Anton Babenko I enjoy AWS, DevOps and web-development. I am AWS Certified Solution Architect, SysOps and DevOps. I work as DevOps engineer at Your.MD. I am one of organizers of AWS User Group Norway meetups ( Next meetup - “Big data experience at Schibsted”, 30th of May, 17:30 at MESH ) github.com/antonbabenko linkedin.com/in/antonbabenko [email protected]
  • 3. What is AWS CodeDeploy? Fully managed service which allows deployment to Amazon EC2 and on-premise instances Requires no modifications to existing code and is technology agnostic Can deploy from Amazon S3 buckets and Github repos Free
  • 4. Getting started Install codedeploy agent Prepare your application (add appspec.yml) Create archive and register application revision Create archive, upload it to S3 and register application revision: aws deploy push Register application revision (can be combined with ghr): aws deploy register-application-revision Configure target environment (“deployment group”)
  • 5. Deploy Deploy application revision (myapp-v1.0.zip) to deployment group (myapp-prod) according to deployment configuration (CodeDeployDefault.OneAtATime): aws deploy create-deployment --application-name myapp --deployment-config-name CodeDeployDefault.OneAtATime --deployment-group-name myapp-prod --description "My app v1.0 deployment to production" --s3-location bucket=myapp-archives,bundleType=zip,key=myapp-v1.0.zip
  • 7. appspec.yml version: 0.0 os: linux files: - source: Config/config.txt destination: webapps/Config - source: source destination: /webapps/myApp # permissions: # skipped on this example hooks: ApplicationStop: - location: codedeploy/playbooks/application_stop.yml BeforeInstall: - location: codedeploy/playbooks/before_install.yml - location: Scripts/UnzipDataBundle.sh AfterInstall: - location: codedeploy/playbooks/after_install.yml ApplicationStart: - location: codedeploy/playbooks/application_start.yml timeout: 3600 ValidateService: - location: Scripts/MonitorService.sh timeout: 3600 runas: codedeployuser
  • 8. codedeploy/playbooks/application_stop.yml #!/usr/bin/env ansible-playbook --- - hosts: localhost gather_facts: false become: true tasks: - name: Stop supervisor service ignore_errors: yes supervisorctl: name: "search" state: stopped
  • 9. Deployment configuration One at a time Half at a time All at once Custom
  • 10. Deployment group Options: One per environment (development-site, staging-site, production-site) Blue-green fashion: production-site-blue + application revision v1.0 production-site-green + application revision v1.1
  • 11. Integrations Github webhooks S3 + AWS Lambda CircleCI, CodeShip, Jenkins, etc AWS Auto-scaling ELB SNS Cloudwatch Cloudtrail Terraform
  • 12. Considerations S3 bucket and CodeDeploy application should be in the same AWS region S3 cross-region replication does not work for private files Solution: Register application revision for each region/bucket individually Take care of created files not managed by CodeDeploy yourself Solution: Use BeforeInstall hook No control of what revision to deploy during ASG scaling activity No straightforward solutions I know, only hacks (wrapper-application, triggers to SNS) Watch out for infinite EC2 restarts during ASG scaling activity Solution: Use ValidateService hook wisely Hint: Test deployments on both running and newly created instances

Editor's Notes

  • #4: * It can be used to deploy to anything connected to internet where Ruby can be installed ** Free for EC2 instances, 2 cents per deployment for on-premise instances *** Deployable content can be code, configuration files, packages, anything.