Contenu connexe Similaire à Automate Testing & Deployment of Modern Serverless Apps (API318-R1) - AWS re:Invent 2018 (20) Plus de Amazon Web Services (20) Automate Testing & Deployment of Modern Serverless Apps (API318-R1) - AWS re:Invent 20182. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Automate Testing & Deployment
of Modern Serverless Applications
Jonathan Clark
Software Development Manager
AWS/Orchestration
A P I 3 1 8 - R
3. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Agenda
Introduction
Deployment Types
Demo
Concepts
Q&A
4. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Chalk talk repeats
Wednesday, November 28
Automate Testing & Deployment of Modern Serverless Apps
2:30PM – 3:30PM | Aria West, Level 3, Ironwood 7, T1
5. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Related chalk talks
Monday, November 26
Deploy a Resilient and Cost-Effective App with EC2 Auto Scaling
and CI/CD
1:00PM – 2:00PM | Mirage, Grand Ballroom B, Table 2
Thursday, November 29
Create a Serverless Web Event Pipeline
4:00PM – 5:00PM | Mirage, Grand Ballroom D, Table 2
Tuesday, November 27
Serverless State Management & Orchestration for Modern Apps
10:45AM – 11:45AM | Bellagio, Level 1, Bellagio Ballroom 6
6. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
7. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
What are Serverless
Applications?
Serverless applications don't
require you to provision, scale,
and manage any servers.
8. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Continuous Integration
Continuous integration is the practice of merging all developer working
copies to a shared “mainline” several times a day
1. Maintain a code repository
2. Automate the build
3. Make the build self-testing
9. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Continuous Deployment
Continuous deployment is the practice in which software functionalities
are delivered frequently through automated deployments
1. Automation infrastructure
2. Define steps for integration
3. Instrument metrics to trigger events
10. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
11. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Types of Deployments
Software can be deployed in a variety of ways, each one with a different
set of benefits/deficits. Some typical deployment types include:
1. Recreate – Shutdown version A and create version B.
2. Ramped – Route a portion of the requests to an updated version.
3. Blue/Green – Create a new stack every deployment and shift traffic.
4. Shadow – Release both versions, send traffic to both and return from A.
12. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Recreate Deployments
Overview
Recreate deployments consist of shutting down the live environment and creating the new
version. This is also called “update” deployments
Pros
• Easy setup.
• Cost-effective.
• No additional deployment code or infrastructure to maintain
Cons
• Downtime between shutting down and creating new environment.
• Rolling back the deployment is more difficult and takes longer.
13. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Ramped Deployments
Overview
Slowly roll out a new version by replacing a subset of the instances. You would take down a
portion of your fleet
Pros
• Control blast radius through parallelism and batching.
• Slow release of new versions
Cons
• With serverless you don’t have control over instances.
• Implement routing logic on top of resources
• No control on traffic
14. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Blue/Green Deployments
Overview
Blue/Green deployments consist of creating another entire environment. Once the new
environment has been validated, route all traffic to it.
Pros
• Instant rollout/rollback – no downtime.
• No versioning issue, deployments are isolated.
Cons
• Expensive as it requires another stack – if serverless, this cost is minimal.
• Handling state in applications through this deployment can be difficult.
• In a bad deployment, impact is large but short-lived.
15. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Shadow Deployments
Overview
Release the new version alongside the old version. Fork traffic from the old version to the new
one.
Pros
• Performance testing for production load is evaluated in the deployment
• Testable with production load before flipping the switch
Cons
• Expensive to set up and maintain
• Requires mocking for idempotent functions
• Requires a routing layer on top of your application
16. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
18. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Extending the Image Processing AWS Sample
• Existing solution allows you to upload an image and run it through
Amazon Rekognition to add tags.
• https://github.com/aws-samples/lambda-refarch-imagerecognition
• The Demo extended it to support text recognition (OCR) in newly
uploaded images
• Desktop to Prod in 3 minutes 49 seconds.
• Using a Recreate deployment type through AWS CloudFormation
• Monitoring and versioning is managed
19. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Adding AWS CodePipeline to the project
• AWS CodeCommit
• Source code repository
• AWS CodeBuild
• Build and test code
• AWS CodeDeploy
• Deployment automation
• AWS CodePipeline
• Visualize and automate deployment
20. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CodeBuild Phases
• install
• Install required dependencies to run tests and build
• pre-build
• Preparation scripts
• build
• Used to package any data or code
• Generate AWS CloudFormation templates
• Create temporary resources and execute tests
• post-build
• Steps to run after the build
21. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CodeBuild Buildspec.yml
version: 0.2
phases:
install:
commands:
# Install commands to run
artifacts:
type: zip
files:
#Output files
22. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
#Install Commands to Run
- npm install -C lambda-
functions/create-s3-event-trigger-
helper
- npm install -C lambda-
functions/thumbnail
- npm install -C lambda-
functions/extract-image-metadata
- echo "Installing Lambda Dependencies
Complete"
- python
cloudformation/inject_state_machine_cfn
.py -s cloudformation/state-
machine.json -c cloudformation/image-
processing.serverless.yaml -o
cloudformation/image-
processing.complete.yaml
- aws cloudformation package --kms-key-
id $CODEBUILD_KMS_KEY_ID --s3-bucket
codepipeline-us-west-2-854096359820 --
template cloudformation/image-
processing.complete.yaml --output-
template-file cloudformation/image-
processing.output.yaml
- echo "Building Complete"
23. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
#Output Files
type: zip
files:
- cloudformation/image-processing.complete.yaml
- cloudformation/image-processing.output.yaml
24. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Application Architecture – Image Processing
25. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Deployment Architecture
26. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Monitoring Dashboard
27. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
28. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Versioning Properties in AWS Lambda
1. Reference through ARN suffix
2. Default is :$LATEST suffix – reference the last updated version
3. Customizable mutable aliases pointing to immutable versions
4. AWS CloudFormation recreates a new Lambda function resource on UpdateStack
5. Rollback accomplished by changing alias or updating $LATEST version.
29. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Versioning Properties in Step Functions
1. Reference through ARN suffix
2. UpdateStateMachine, DescribeStateMachineForExecution are key APIs
3. Old state machine executions continue to run, new state machines run the new version
4. AWS CloudFormation increases the version of the state machine
5. Rollback accomplished by updating state machine
30. Thank you!
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Jonathan Clark
jonaclar@amazon.com
31. Time: 15 minutes after this session
Location: Speaker Lounge (ARIA East, Level 1, Willow Lounge)
Duration: 30 min.
32. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.