Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Automate Software Deployments on EC2 with AWS CodeDeploy

1,865 views

Published on

by Hubert Cheung, Solution Architect, AWS

  • Get the best essay, research papers or dissertations. from ⇒ www.HelpWriting.net ⇐ A team of professional authors with huge experience will give u a result that will overcome your expectations.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • If you’re looking for a great essay service then you should check out ⇒ www.WritePaper.info ⇐. A friend of mine asked them to write a whole dissertation for him and he said it turned out great! Afterwards I also ordered an essay from them and I was very happy with the work I got too.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • ⇒ www.HelpWriting.net ⇐ This service will write as best as they can. So you do not need to waste the time on rewritings.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Hi there! I just wanted to share a list of sites that helped me a lot during my studies: .................................................................................................................................... www.EssayWrite.best - Write an essay .................................................................................................................................... www.LitReview.xyz - Summary of books .................................................................................................................................... www.Coursework.best - Online coursework .................................................................................................................................... www.Dissertations.me - proquest dissertations .................................................................................................................................... www.ReMovie.club - Movies reviews .................................................................................................................................... www.WebSlides.vip - Best powerpoint presentations .................................................................................................................................... www.WritePaper.info - Write a research paper .................................................................................................................................... www.EddyHelp.com - Homework help online .................................................................................................................................... www.MyResumeHelp.net - Professional resume writing service .................................................................................................................................. www.HelpWriting.net - Help with writing any papers ......................................................................................................................................... Save so as not to lose
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • You can get paid up to $25 per hour to be on Facebook? ➤➤ http://t.cn/AieXiXbg
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Automate Software Deployments on EC2 with AWS CodeDeploy

  1. 1. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Hubert Cheung AWS Solutions Architect Automate Software Deployments on EC2 with AWS CodeDeploy
  2. 2. Aboot Me Hubert Cheung hubertc@amazon.com Solutions Architect Canuck @ AWS 4.5 Years - AWS Support - AWS Solutions Architecture
  3. 3. https://secure.flickr.com/photos/mgifford/4525333972 Why are we here today?
  4. 4. • Integration tests with other systems • Load testing • UI tests • Penetration testing Release processes have four major phases Source Build Test Production • Check-in source code such as .java files. • Peer review new code • Compile code • Unit tests • Style checkers • Code metrics • Create container images • Deployment to production environments
  5. 5. Release processes levels Source Build Test Production Continuous integration Continuous delivery Continuous deployment
  6. 6. AWS Code* Services AWS CodePipeline AWS CodeCommit AWS CodeBuildAWS CodeDeploy
  7. 7. AWS Code Services Source Build Test Production Software Release Phases:
  8. 8. AWS Code Services Source Build Test Production Software Release Phases: AWS CodeCommit
  9. 9. AWS Code Services Source Build Test Production Software Release Phases: AWS CodeBuild
  10. 10. AWS Code Services Source Build Test Production Software Release Phases: Third Party Tooling
  11. 11. AWS Code Services Source Build Test Production Software Release Phases: AWS CodeDeploy
  12. 12. AWS Code Services Source Build Test Production Software Release Phases: EC2 On-Prem AWS CodeDeploy
  13. 13. AWS Code Services Source Build Test Production Software Release Phases: AWS CodePipeline
  14. 14. AWS Code Services Source Build Test Production Third Party Tooling Software Release Phases: AWS CodeCommit AWS CodeBuild AWS CodeDeploy AWS CodePipeline
  15. 15. AWS Code Services Source Build Test Production Third Party Tooling Software Release Phases: AWS CodeCommit AWS CodeDeploy AWS CodePipeline
  16. 16. Orchestrating build and deploy with a pipeline https://www.flickr.com/photos/seattlemunicipalarchives/12504672623/
  17. 17. Continuous delivery service for fast and reliable application updates Model and visualize your software release process Builds, tests, and deploys your code every time there is a code change Integrates with third-party tools and AWS AWS CodePipeline
  18. 18. Source Source GitHub Build CodeBuild AWS CodeBuild Deploy JavaApp Elastic Beanstalk Pipeline Stage Action Transition CodePipeline MyApplication
  19. 19. Build CodeBuild AWS CodeBuild NotifyDevelopers Lambda Parallel actions Source Source GitHub CodePipeline MyApplication Deploy JavaApp Elastic Beanstalk
  20. 20. Build CodeBuild AWS CodeBuild NotifyDevelopers Lambda TestAPI Runscope Sequential actions Deploy JavaApp Elastic Beanstalk Source Source GitHub CodePipeline MyApplication
  21. 21. Build CodeBuild AWS CodeBuild Staging-Deploy JavaApp Elastic Beanstalk Prod-Deploy JavaApp Elastic Beanstalk QATeamReview Manual Approval Manual Approvals Review CodePipeline MyApplication
  22. 22. 8. Retrieve build artifact EC2 instance Source Source GitHub Build JenkinsOnEC2 Jenkins Deploy JavaApp Elastic Beanstalk Source Artifact S3 Build Artifact S3 5. Get source artifact 1. Get Changes 6. Store build artifact 3. Poll for Job 4. Acknowledge Job 7. Put Success 9. Deploy build artifact Elastic Beanstalk Web container Java App CodePipeline MyApplication
  23. 23. AWS service integrations Source Invoke Logic Deploy AWS Elastic Beanstalk Amazon S3 AWS CodeDeployAWS Lambda AWS CodeCommit AWS OpsWorks AWS CloudFormation
  24. 24. We have a strong partner list, and it’s growing Source Build Test Deploy
  25. 25. Extend AWS CodePipeline Using Custom Actions Update tickets Provision resources Update dashboards Mobile testing Send notifications Security scan
  26. 26. Storing your code
  27. 27. Secure, scalable, and managed Git source control Use standard Git tools Scalability, availability, and durability of Amazon S3 Encryption at rest with customer-specific keys No repo size limit Post commit hooks to call out to SNS/Lambda AWS CodeCommit
  28. 28. Source control in the cloud Secure Fully managed High availability Store anything
  29. 29. AWS CodeCommit git pull/push CodeCommit Git objects in Amazon S3 Git index in Amazon DynamoDB Encryption key in AWS KMS SSH or HTTPS
  30. 30. Build & test your application https://secure.flickr.com/photos/spenceyc/7481166880
  31. 31. Fully managed build service that compiles source code, runs tests, and produces software packages Scales continuously and processes multiple builds concurrently You can provide custom build environments suited to your needs via Docker images Only pay by the minute for the compute resources you use Launched with CodePipeline and Jenkins integration AWS CodeBuild
  32. 32. How does it work? 1. Downloads source code 2. Executes commands configured in the buildspec in temporary compute containers (created fresh on every build) 3. Streams the build output to the service console and CloudWatch logs 4. Uploads the generated artifact to an S3 bucket
  33. 33. How can I automate my release process with CodeBuild? • Integrated with AWS CodePipeline for CI/CD • Easily pluggable (API/CLI driven) • Bring your own build environments • Create Docker images containing tools you need • Open source Jenkins plugin • Use CodeBuild as the workers off of a Jenkins master
  34. 34. No Building Required! Many languages don’t require building. These are considered interpreted languages: • PHP • Ruby • Python • Node.js You can just deploy your code! EC2
  35. 35. Testing Your Code Testing is both a science and an art form! Goals for testing your code: • Want to confirm desired functionality • Catch programming syntax errors • Standardize code patterns and format • Reduce bugs due to non-desired application usage and logic failures • Make applications more secure
  36. 36. Where to Focus Your Tests: UI Service Unit 70% 20% 10%
  37. 37. What service and release step corresponds with which tests? Third Party Tooling AWS CodeBuild BuildTest
  38. 38. Deploying your applications https://secure.flickr.com/photos/simononly/15386966677
  39. 39. Automates code deployments to any instance Handles the complexity of updating your applications Avoid downtime during application deployment Rollback automatically if failure detected Deploy to Amazon EC2 or on-premises servers, in any language and on any operating system Integrates with third-party tools and AWS AWS CodeDeploy
  40. 40. AWS CodeDeploy - Components Application: What you are deploying – A container for revisions Revision: A given version of your application Instance: Target instance for deployment Deployment Groups: Group of instances – A construct for environment segregation (Dev/QA/Prod, Blue/Green, A/B, etc.) AppSpec File: Describes actions that needs to be taken pre- or post-deployment Deployment: The action of deploying a new revision onto instances
  41. 41. AWS CodeDeploy - Application • The Application is the highest level container • Revisions will be attached to the Application
  42. 42. AWS CodeDeploy - Revisions Revisions are versions of your application They can be uploaded to: • Amazon S3 • GitHub Revisions are deployed onto Deployment Groups, which are groups of instance
  43. 43. AWS CodeDeploy – Instance Setup • Verify your instance has an IAM instance profile and verify the permissions allows it to participate in AWS CodeDeploy deployments • Tag the instance - or make sure it’s in an Auto Scaling Group • Install the agent (can be automated) • Verify the agent is running
  44. 44. AWS CodeDeploy – Setup Deployment Groups Group instances by: • Auto Scaling Groups • EC2 Tags • On-Premise tags Deploy to Deployment Groups independently from each other Could be used for “DevOps” constructs: • Dev/QA/Prod/etc. • Blue/Green • A/B Testing • Etc.
  45. 45. AWS CodeDeploy – Lifecycle Events AfterInstall ApplicationStart ValidateService ApplicationStop BeforeInstall Agent The agent goes through a series of steps before and after deployment These steps allow you to tightly control how your application is deployed For example, you may want to stop your application cleanly
  46. 46. AWS CodeDeploy – AppSpec File version: 0.0 os: linux files: - source: / destination: /var/www/html/WordPress hooks: ApplicationStop: - location: helper_scripts/stop_server.sh BeforeInstall: - location: deploy_hooks/install-apache.sh - location: deploy_hooks/install-mysql.sh AfterInstall: - location: deploy_hooks /configure_app.sh timeout: 30 runas: root • AppSpec.yml sits in your application’s source directory structure • Allows you to defines the hooks you want to use.
  47. 47. appspec.yml Example version: 0.0 os: linux files: - source: / destination: /var/www/html permissions: - object: /var/www/html pattern: “*.html” owner: root group: root mode: 755 hooks: ApplicationStop: - location: scripts/deregister_from_elb.sh BeforeInstall: - location: scripts/install_dependencies.sh ApplicationStart: - location: scripts/start_httpd.sh ValidateService: - location: scripts/test_site.sh - location: scripts/register_with_elb.sh
  48. 48. appspec.yml Example version: 0.0 os: linux files: - source: / destination: /var/www/html permissions: - object: /var/www/html pattern: “*.html” owner: root group: root mode: 755 hooks: ApplicationStop: - location: scripts/deregister_from_elb.sh BeforeInstall: - location: scripts/install_dependencies.sh ApplicationStart: - location: scripts/start_httpd.sh ValidateService: - location: scripts/test_site.sh - location: scripts/register_with_elb.sh • Remove/add instance to ELB • Install dependency packages • Start Apache • Confirm successful deploy • More! • Send application files to one directory and configuration files to another • Set specific permissions on specific directories & files
  49. 49. AWS CodeDeploy – Deployment Configuration One-at-a-time Half-at-a-time All-at-once Custom Blue / Green Deployments supported as of January 2017
  50. 50. DEMO!
  51. 51. Wrap up http://www.gratisography.com
  52. 52. Code* Tips and Tricks • All Code* products can(and should) be provisioned and managed with AWS CloudFormation! • You could literally store the CloudFormation templates that provision your Code* resources in CodeCommit and update them via CodePipeline (It’s like Code* Inception!) • Deep integration with IAM. You can assign permissions on who can commit code, approve manual approvals, deploy to certain deployment groups and more! • Integrate with AWS Lambda to do almost anything: • CodeCommit has Repository Triggers • CodeDeploy has Event Notifications • CodePipeline has native Lambda invoke AWS CodePipeline AWS CodeCommit AWS CodeBuildAWS CodeDeploy
  53. 53. aws.amazon.com/devops
  54. 54. AWS DevOps Blog
  55. 55. ? https://secure.flickr.com/photos/dullhunk/202872717/

×