AWS CodeDeploy - basic intro
-
Upload
anton-babenko -
Category
Technology
-
view
199 -
download
1
Transcript of AWS CodeDeploy - basic intro
![Page 1: AWS CodeDeploy - basic intro](https://reader033.fdocuments.in/reader033/viewer/2022061513/58ee22731a28ab5a2a8b46c9/html5/thumbnails/1.jpg)
AWS CodeDeployBy Anton Babenko, May 2016
![Page 2: AWS CodeDeploy - basic intro](https://reader033.fdocuments.in/reader033/viewer/2022061513/58ee22731a28ab5a2a8b46c9/html5/thumbnails/2.jpg)
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]
![Page 3: AWS CodeDeploy - basic intro](https://reader033.fdocuments.in/reader033/viewer/2022061513/58ee22731a28ab5a2a8b46c9/html5/thumbnails/3.jpg)
What is AWS CodeDeploy?
Fully managed service which allows deployment to Amazon EC2 and on-premise instancesRequires no modifications to existing code and is technology agnosticCan deploy from Amazon S3 buckets and Github reposFree
![Page 4: AWS CodeDeploy - basic intro](https://reader033.fdocuments.in/reader033/viewer/2022061513/58ee22731a28ab5a2a8b46c9/html5/thumbnails/4.jpg)
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 application revision
![Page 5: AWS CodeDeploy - basic intro](https://reader033.fdocuments.in/reader033/viewer/2022061513/58ee22731a28ab5a2a8b46c9/html5/thumbnails/5.jpg)
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
![Page 6: AWS CodeDeploy - basic intro](https://reader033.fdocuments.in/reader033/viewer/2022061513/58ee22731a28ab5a2a8b46c9/html5/thumbnails/6.jpg)
Execution flow
![Page 7: AWS CodeDeploy - basic intro](https://reader033.fdocuments.in/reader033/viewer/2022061513/58ee22731a28ab5a2a8b46c9/html5/thumbnails/7.jpg)
appspec.ymlversion: 0.0os: linuxfiles: - source: Config/config.txt destination: webapps/Config - source: source destination: /webapps/myApp# permissions: # skipped on this examplehooks: 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
![Page 8: AWS CodeDeploy - basic intro](https://reader033.fdocuments.in/reader033/viewer/2022061513/58ee22731a28ab5a2a8b46c9/html5/thumbnails/8.jpg)
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
![Page 9: AWS CodeDeploy - basic intro](https://reader033.fdocuments.in/reader033/viewer/2022061513/58ee22731a28ab5a2a8b46c9/html5/thumbnails/9.jpg)
Deployment configurationOne at a time
Half at a time
All at once
Custom
![Page 10: AWS CodeDeploy - basic intro](https://reader033.fdocuments.in/reader033/viewer/2022061513/58ee22731a28ab5a2a8b46c9/html5/thumbnails/10.jpg)
Deployment groupOptions:
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
![Page 11: AWS CodeDeploy - basic intro](https://reader033.fdocuments.in/reader033/viewer/2022061513/58ee22731a28ab5a2a8b46c9/html5/thumbnails/11.jpg)
IntegrationsGithub webhooks
S3 + AWS Lambda
CircleCI, CodeShip, Jenkins, etc
AWS
Auto-scaling
ELB
SNS
Cloudwatch
Cloudtrail
Terraform
aws_codedeploy_app
aws_codedeploy_deployment_group
![Page 12: AWS CodeDeploy - basic intro](https://reader033.fdocuments.in/reader033/viewer/2022061513/58ee22731a28ab5a2a8b46c9/html5/thumbnails/12.jpg)
ConsiderationsS3 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
Execution logs are not available in console if deployment was successful
Solution: Always stream logs somewhere (for eg, AWS Cloudwatch)
Note: CodeDeploy has been designed to deploy single application per EC2 instance.
![Page 13: AWS CodeDeploy - basic intro](https://reader033.fdocuments.in/reader033/viewer/2022061513/58ee22731a28ab5a2a8b46c9/html5/thumbnails/13.jpg)
Thank you!Questions ?