Continuous Integration and 
Deployment Best Practices on AWS 
Adrian White 
Solutions Architect, Amazon Web Services 
© 20...
Innovation, Quality, Governance
Stacks / 
Environment(s) 
An example CI / CD workflow 
CI/CD tool 
Issue 
Tracker 
SCM 
Infrastructure 
automation / 
depl...
An example CI / CD workflow 
PHPUnit 
jQuery 
… 
Tasks for AWS 
CloudFormation Stack(s)
A CI / CD pipeline 
Code 
Test 
Deploy 
Release 
Teardown
Get your source under control 
Prod UAT Phoenix (feature) 
Code 
Test 
Deploy 
Release 
Teardown 
Code 
Test 
Deploy 
Rele...
Automated Merging 
UAT Feature 1 Feature 2
What does CI give us? 
• Test driven promotion (of development change) 
• Increasing velocity of feedback cycle through 
i...
Demo 1: CI pipeline
What does CD give us? 
• Changes are pushed quickly to production 
• Immediate feedback from users 
• Supports A/B testing...
Deployment approaches 
• Deploy in place 
– Manage interruption 
• Bake 
– Discrete environment 
Deploy Deploy in-place 
•...
Deploy in-place 
Un-baked 
• Common baseline AMI 
• Customise at instantiation 
• Change in-place 
Your app 
AMI
Deploy in-place 
Un-baked 
• Common baseline AMI 
• Customise at instantiation 
• Change in-place 
Your app 
AMI
Deploy in-place 
Un-baked 
• Common baseline AMI 
• Customise at instantiation 
• Change in-place 
Your app 
AMI
Deploy in-place 
Un-baked 
• Common baseline AMI 
• Customise at instantiation 
• Change in-place 
Your app 
AMI
Deploy in-place 
Un-baked 
• Common baseline AMI 
• Customise at instantiation 
• Change in-place 
Your app 
AMI
Deploy in-place 
Un-baked 
• Common baseline AMI 
• Customise at instantiation 
• Change in-place 
Your app 
AMI
Bake process 
1. Start a builder instance 
2. Bootstrap / cfn-init, cfn-signal 
3. Bake your AMI 
4. Tag it 
5. Destroy/cl...
cfn-init 
"AWS::CloudFormation::Init" : { 
“cfn” : { 
"packages" :{ 
"yum" : { "httpd" : [] } 
}, 
"files":{ 
“/home/ec2-u...
cfn-init 
"services": { 
"sysvinit" : { 
"httpd" : { 
"enabled" : "true", 
"ensureRunning" : "true" 
} 
} 
} 
}
Demo 2: CD pipeline
Release 
awssummit.com 
awssummit-1.com awssummit-2.com
Release 
Release 
Test the new stack 
Match the traffic between the two stacks 
Update the “floating” DNS record 
Send Not...
Blue green deployment 
awssummit.com 
awssummit-1.com awssummit-2.com
Blue green deployment 
awssummit.com 
awssummit-1.com awssummit-2.com
Blue green deployment 
awssummit.com 
awssummit-1.com awssummit-2.com
Blue green deployment 
awssummit.com 
awssummit-1.com awssummit-2.com
Teardown 
Teardown 
Ensure that no traffic is moving though ELB 
Teardown the CloudFormation Stack 
Deregister the AMI
Advanced Techniques 
• Managing CD sprawl / Segregation of duties 
• Extending CloudFormation with custom 
resources 
• Ex...
Stack chaining
Stack chaining
Stack chaining
CloudFormation Merging 
CloudFormation 
VPC 
Subnets 
Security Groups 
CloudFormation Frameworks 
Best Practice 
Applicati...
CloudFormation Custom Resources 
• Change DB schema during deployment 
Parameters 
• Extend CloudFormation to support othe...
Custom resources – DatabaseSchema 
"MyDBSchema" : { 
"Type" : "Custom::DatabaseSchema”, "Version" : "1.0", 
"Properties" :...
Custom resources – DatabaseSchema 
"createTable" : { 
"tableName" : "example", 
"columns" : [ { 
"column" : { 
"name" : "i...
Extending your CD tools 
Tasks for AWS 
DynamoDB
Demo 2: Release 
2 
1 
Code 
Test 
Deploy 
Release 
Teardown 
Production 
Code 
Test 
Deploy 
Release 
Teardown
Situational Awareness 
Burden of Responsibility 
APIs 
Tasks for AWS
Containerisation 
• Build environments for artifacts, don’t update 
environments with artifacts 
• All environments are tr...
Docker, Amazon Linux and Elastic 
Beanstalk 
• A framework for managing containers 
• LXC containers are more lightweight ...
Innovation, Quality, Governance 
Discrete environments for each branch 
Leverage CD tools to provide separation of duties ...
Expand your skills with AWS 
Certification 
Exams 
Validate your proven 
technical expertise with 
the AWS platform 
aws.a...
© 2014 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified, or distributed in whole or i...
Upcoming SlideShare
Loading in...5
×

Continuous Integration and Deployment Best Practices on AWS

1,302

Published on

AWS Summit 2014 Perth - Breakout 6

With AWS companies now have the ability to develop and run their applications with speed and flexibility like never before. Working with an infrastructure that can be 100% API driven enables businesses to use lean methodologies and realize these benefits. This in turn leads to greater success for those who make use of these practices. In this session we'll talk about some key concepts and design patterns for Continuous Deployment and Continuous Integration, two elements of lean development of applications and infrastructures.

Presenter: Adrian White, Solutions Architect, Amazon Web Services

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,302
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
0
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Transcript of "Continuous Integration and Deployment Best Practices on AWS"

  1. 1. Continuous Integration and Deployment Best Practices on AWS Adrian White Solutions Architect, Amazon Web Services © 2014 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified, or distributed in whole or in part without the express consent of Amazon.com, Inc.
  2. 2. Innovation, Quality, Governance
  3. 3. Stacks / Environment(s) An example CI / CD workflow CI/CD tool Issue Tracker SCM Infrastructure automation / deployment Test tools / harnesses
  4. 4. An example CI / CD workflow PHPUnit jQuery … Tasks for AWS CloudFormation Stack(s)
  5. 5. A CI / CD pipeline Code Test Deploy Release Teardown
  6. 6. Get your source under control Prod UAT Phoenix (feature) Code Test Deploy Release Teardown Code Test Deploy Release Teardown Code Test Deploy Release Teardown Code Test Deploy Release Teardown
  7. 7. Automated Merging UAT Feature 1 Feature 2
  8. 8. What does CI give us? • Test driven promotion (of development change) • Increasing velocity of feedback cycle through iterative change • Contain change to reduce risk • Bugs are detected quickly • Automated testing reduces size of testing effort
  9. 9. Demo 1: CI pipeline
  10. 10. What does CD give us? • Changes are pushed quickly to production • Immediate feedback from users • Supports A/B testing or “We test customer reactions to features in production” • Hardens, de-risks the deployment process • Gives us a breadth of data points across our applications
  11. 11. Deployment approaches • Deploy in place – Manage interruption • Bake – Discrete environment Deploy Deploy in-place • Multiple environments from branches • Support A/B testing • “Rolling DNS” Bake
  12. 12. Deploy in-place Un-baked • Common baseline AMI • Customise at instantiation • Change in-place Your app AMI
  13. 13. Deploy in-place Un-baked • Common baseline AMI • Customise at instantiation • Change in-place Your app AMI
  14. 14. Deploy in-place Un-baked • Common baseline AMI • Customise at instantiation • Change in-place Your app AMI
  15. 15. Deploy in-place Un-baked • Common baseline AMI • Customise at instantiation • Change in-place Your app AMI
  16. 16. Deploy in-place Un-baked • Common baseline AMI • Customise at instantiation • Change in-place Your app AMI
  17. 17. Deploy in-place Un-baked • Common baseline AMI • Customise at instantiation • Change in-place Your app AMI
  18. 18. Bake process 1. Start a builder instance 2. Bootstrap / cfn-init, cfn-signal 3. Bake your AMI 4. Tag it 5. Destroy/clean up the builder instance
  19. 19. cfn-init "AWS::CloudFormation::Init" : { “cfn” : { "packages" :{ "yum" : { "httpd" : [] } }, "files":{ “/home/ec2-user/myfile.html:{ "source" : { "Fn::Join" : [ "", ["https://s3-ap-southeast- 2.amazonaws.com/",{ "Ref" : "S3Bucket" },”/myfile.html”]] }, "mode":"000644", "owner":"root", "group":"root", "authentication":"S3AccessCreds” },
  20. 20. cfn-init "services": { "sysvinit" : { "httpd" : { "enabled" : "true", "ensureRunning" : "true" } } } }
  21. 21. Demo 2: CD pipeline
  22. 22. Release awssummit.com awssummit-1.com awssummit-2.com
  23. 23. Release Release Test the new stack Match the traffic between the two stacks Update the “floating” DNS record Send Notification(s) ROLLBACK
  24. 24. Blue green deployment awssummit.com awssummit-1.com awssummit-2.com
  25. 25. Blue green deployment awssummit.com awssummit-1.com awssummit-2.com
  26. 26. Blue green deployment awssummit.com awssummit-1.com awssummit-2.com
  27. 27. Blue green deployment awssummit.com awssummit-1.com awssummit-2.com
  28. 28. Teardown Teardown Ensure that no traffic is moving though ELB Teardown the CloudFormation Stack Deregister the AMI
  29. 29. Advanced Techniques • Managing CD sprawl / Segregation of duties • Extending CloudFormation with custom resources • Extending your CD tools
  30. 30. Stack chaining
  31. 31. Stack chaining
  32. 32. Stack chaining
  33. 33. CloudFormation Merging CloudFormation VPC Subnets Security Groups CloudFormation Frameworks Best Practice Application Code Application CloudFormation Load Balancing Setup Git Git Operations Repo Application Repo
  34. 34. CloudFormation Custom Resources • Change DB schema during deployment Parameters • Extend CloudFormation to support other services - “So You Think You Are An AWS Ninja” talk Custom resource implementation https://github.com/aws/aws-cfn-resource-bridge https://github.com/awslabs/aws-cfn-custom-resource-examples Git
  35. 35. Custom resources – DatabaseSchema "MyDBSchema" : { "Type" : "Custom::DatabaseSchema”, "Version" : "1.0", "Properties" : { "ServiceToken": "arn:aws:sns:us-east-1:12345EXAMPLE:DBSchema", "databaseChangeLog" : [ { "changeSet" : { "id" : "1", "author" : "adamthom", "changes" : [ { "createTable" : { … } } ] } } } }
  36. 36. Custom resources – DatabaseSchema "createTable" : { "tableName" : "example", "columns" : [ { "column" : { "name" : "id", "type" : "int", "autoIncrement" : true, "constraints" : { "primaryKey" : true, "nullable" : false } } } ] }
  37. 37. Extending your CD tools Tasks for AWS DynamoDB
  38. 38. Demo 2: Release 2 1 Code Test Deploy Release Teardown Production Code Test Deploy Release Teardown
  39. 39. Situational Awareness Burden of Responsibility APIs Tasks for AWS
  40. 40. Containerisation • Build environments for artifacts, don’t update environments with artifacts • All environments are transient • Standardisation, abstraction and portability
  41. 41. Docker, Amazon Linux and Elastic Beanstalk • A framework for managing containers • LXC containers are more lightweight than VMs • Amazon Linux (2014.03) bundles Docker 0.9 and LXC 0.9 • Docker containers on Beanstalk are Go!
  42. 42. Innovation, Quality, Governance Discrete environments for each branch Leverage CD tools to provide separation of duties Automated testing on every commit on every branch Audit Logs Git approvals process Leverage DNS Use custom resources to extend CloudFormation Interface with the API Environments for artifacts
  43. 43. Expand your skills with AWS Certification Exams Validate your proven technical expertise with the AWS platform aws.amazon.com/certification On-Demand Resources Videos & Labs Get hands-on practice working with AWS technologies in a live environment aws.amazon.com/training/ self-paced-labs Instructor-Led Courses Training Classes Expand your technical expertise to design, deploy, and operate scalable, efficient applications on AWS aws.amazon.com/training
  44. 44. © 2014 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified, or distributed in whole or in part without the express consent of Amazon.com, Inc.

×