SlideShare uma empresa Scribd logo
1 de 13
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 ?

Mais conteúdo relacionado

Mais procurados

End-to-end CI/CD deployments of containerized applications using AWS services
End-to-end CI/CD deployments of containerized applications using AWS servicesEnd-to-end CI/CD deployments of containerized applications using AWS services
End-to-end CI/CD deployments of containerized applications using AWS services
Massimo Ferre'
 
[Jun AWS 201] Elastic Beanstalk for Startups
[Jun AWS 201] Elastic Beanstalk for Startups[Jun AWS 201] Elastic Beanstalk for Startups
[Jun AWS 201] Elastic Beanstalk for Startups
Amazon Web Services Korea
 

Mais procurados (20)

Using Amazon CloudWatch Events, AWS Lambda and Spark Streaming to Process EC...
 Using Amazon CloudWatch Events, AWS Lambda and Spark Streaming to Process EC... Using Amazon CloudWatch Events, AWS Lambda and Spark Streaming to Process EC...
Using Amazon CloudWatch Events, AWS Lambda and Spark Streaming to Process EC...
 
Ansible Introduction
Ansible IntroductionAnsible Introduction
Ansible Introduction
 
End-to-end CI/CD deployments of containerized applications using AWS services
End-to-end CI/CD deployments of containerized applications using AWS servicesEnd-to-end CI/CD deployments of containerized applications using AWS services
End-to-end CI/CD deployments of containerized applications using AWS services
 
AWS CloudFormation (February 2016)
AWS CloudFormation (February 2016)AWS CloudFormation (February 2016)
AWS CloudFormation (February 2016)
 
C# Async on iOS and Android - Craig Dunn, Developer Evangelist at Xamarin
C# Async on iOS and Android - Craig Dunn, Developer Evangelist at XamarinC# Async on iOS and Android - Craig Dunn, Developer Evangelist at Xamarin
C# Async on iOS and Android - Craig Dunn, Developer Evangelist at Xamarin
 
goployer, 코드 기반의 배포 도구 - 송주영 (beNX) :: AWS Community Day 2020
goployer, 코드 기반의 배포 도구 - 송주영 (beNX) :: AWS Community Day 2020goployer, 코드 기반의 배포 도구 - 송주영 (beNX) :: AWS Community Day 2020
goployer, 코드 기반의 배포 도구 - 송주영 (beNX) :: AWS Community Day 2020
 
Packer, Terraform, Ansible avec Azure
Packer, Terraform, Ansible avec AzurePacker, Terraform, Ansible avec Azure
Packer, Terraform, Ansible avec Azure
 
Multi host container networking
Multi host container networkingMulti host container networking
Multi host container networking
 
[Jun AWS 201] Elastic Beanstalk for Startups
[Jun AWS 201] Elastic Beanstalk for Startups[Jun AWS 201] Elastic Beanstalk for Startups
[Jun AWS 201] Elastic Beanstalk for Startups
 
Building a Serverless Pipeline
Building a Serverless PipelineBuilding a Serverless Pipeline
Building a Serverless Pipeline
 
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
 
Where is my scalable API?
Where is my scalable API?Where is my scalable API?
Where is my scalable API?
 
Build and deployment with Jenkins and Code Deploy on AWS
Build and deployment with Jenkins and Code Deploy on AWSBuild and deployment with Jenkins and Code Deploy on AWS
Build and deployment with Jenkins and Code Deploy on AWS
 
2016 05-cloudsoft-amp-and-brooklyn-new
2016 05-cloudsoft-amp-and-brooklyn-new2016 05-cloudsoft-amp-and-brooklyn-new
2016 05-cloudsoft-amp-and-brooklyn-new
 
DevOps for the Enterprise: Continuous Integration
DevOps for the Enterprise: Continuous IntegrationDevOps for the Enterprise: Continuous Integration
DevOps for the Enterprise: Continuous Integration
 
초기 스타트업의 AWS - 김지훈(투어라이브) :: AWS Community Day Online 2020
초기 스타트업의 AWS - 김지훈(투어라이브) :: AWS Community Day Online 2020초기 스타트업의 AWS - 김지훈(투어라이브) :: AWS Community Day Online 2020
초기 스타트업의 AWS - 김지훈(투어라이브) :: AWS Community Day Online 2020
 
CI/CD Using Ansible and Jenkins for Infrastructure
CI/CD Using Ansible and Jenkins for InfrastructureCI/CD Using Ansible and Jenkins for Infrastructure
CI/CD Using Ansible and Jenkins for Infrastructure
 
T3 - Deploy, manage, and scale your apps
T3 - Deploy, manage, and scale your appsT3 - Deploy, manage, and scale your apps
T3 - Deploy, manage, and scale your apps
 
Building serverless apps with Node.js
Building serverless apps with Node.jsBuilding serverless apps with Node.js
Building serverless apps with Node.js
 
Meeyup aws-loadbalancing-28032015
Meeyup aws-loadbalancing-28032015Meeyup aws-loadbalancing-28032015
Meeyup aws-loadbalancing-28032015
 

Semelhante a AWS CodeDeploy - basic intro

TLS303 How to Deploy Python Applications on AWS Elastic Beanstalk - AWS re:In...
TLS303 How to Deploy Python Applications on AWS Elastic Beanstalk - AWS re:In...TLS303 How to Deploy Python Applications on AWS Elastic Beanstalk - AWS re:In...
TLS303 How to Deploy Python Applications on AWS Elastic Beanstalk - AWS re:In...
Amazon Web Services
 
Parse cloud code
Parse cloud codeParse cloud code
Parse cloud code
維佋 唐
 
Cannibalising The Google App Engine
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Engine
catherinewall
 

Semelhante a AWS CodeDeploy - basic intro (20)

TLS303 How to Deploy Python Applications on AWS Elastic Beanstalk - AWS re:In...
TLS303 How to Deploy Python Applications on AWS Elastic Beanstalk - AWS re:In...TLS303 How to Deploy Python Applications on AWS Elastic Beanstalk - AWS re:In...
TLS303 How to Deploy Python Applications on AWS Elastic Beanstalk - AWS re:In...
 
Running Microservices on AWS Elastic Beanstalk
Running Microservices on AWS Elastic BeanstalkRunning Microservices on AWS Elastic Beanstalk
Running Microservices on AWS Elastic Beanstalk
 
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
 
Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...
Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...
Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...
 
DevOps for the Enterprise: Virtual Office Hours
DevOps for the Enterprise: Virtual Office HoursDevOps for the Enterprise: Virtual Office Hours
DevOps for the Enterprise: Virtual Office Hours
 
AWS CodeDeploy + Github
AWS CodeDeploy + GithubAWS CodeDeploy + Github
AWS CodeDeploy + Github
 
Continuous Deployment @ AWS Re:Invent
Continuous Deployment @ AWS Re:InventContinuous Deployment @ AWS Re:Invent
Continuous Deployment @ AWS Re:Invent
 
Continuous Integration and Deployment Best Practices on AWS (ARC307) | AWS re...
Continuous Integration and Deployment Best Practices on AWS (ARC307) | AWS re...Continuous Integration and Deployment Best Practices on AWS (ARC307) | AWS re...
Continuous Integration and Deployment Best Practices on AWS (ARC307) | AWS re...
 
Hosting Your Own OTA Update Service
Hosting Your Own OTA Update ServiceHosting Your Own OTA Update Service
Hosting Your Own OTA Update Service
 
Parse cloud code
Parse cloud codeParse cloud code
Parse cloud code
 
Kubernetes for the PHP developer
Kubernetes for the PHP developerKubernetes for the PHP developer
Kubernetes for the PHP developer
 
Application Deployment on AWS - Startup Talks June 2015
Application Deployment on AWS - Startup Talks June 2015Application Deployment on AWS - Startup Talks June 2015
Application Deployment on AWS - Startup Talks June 2015
 
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
 
AWS Webcast - Build Agile Applications in AWS Cloud for Government
AWS Webcast - Build Agile Applications in AWS Cloud for GovernmentAWS Webcast - Build Agile Applications in AWS Cloud for Government
AWS Webcast - Build Agile Applications in AWS Cloud for Government
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
 
Deploy, Manage, and Scale Your Apps with OpsWorks and Elastic Beanstalk
Deploy, Manage, and Scale Your Apps with OpsWorks and Elastic BeanstalkDeploy, Manage, and Scale Your Apps with OpsWorks and Elastic Beanstalk
Deploy, Manage, and Scale Your Apps with OpsWorks and Elastic Beanstalk
 
A 60-minute tour of AWS Compute (November 2016)
A 60-minute tour of AWS Compute (November 2016)A 60-minute tour of AWS Compute (November 2016)
A 60-minute tour of AWS Compute (November 2016)
 
Capifony. Minsk PHP MeetUp #11
Capifony. Minsk PHP MeetUp #11Capifony. Minsk PHP MeetUp #11
Capifony. Minsk PHP MeetUp #11
 
AWS Elastic Beanstalk - Running Microservices and Docker
AWS Elastic Beanstalk - Running Microservices and DockerAWS Elastic Beanstalk - Running Microservices and Docker
AWS Elastic Beanstalk - Running Microservices and Docker
 
Cannibalising The Google App Engine
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Engine
 

Mais de Anton Babenko

Mais de Anton Babenko (20)

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

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
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
 

Último (20)

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 
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
 

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 anton@antonbabenko.com
  • 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

Notas do Editor

  1. * 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.