47
AWS Cloud Kata for Start-Ups and Developers Taipei Managing the Continuous Delivery of Codes to AWS Lambda Pahud Hsieh 拽ၒ௮

管理程式對AWS LAMBDA持續交付

Embed Size (px)

Citation preview

Page 1: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

Taipei

Managing the Continuous Delivery of Codes to AWS Lambda

Pahud Hsieh

Page 2: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

What is AWS Lambda?

Challenges in serverless development

Environment pinning with API Gateway and Lambda

Continuous delivery in different scenarios

Best practices in security and development

Demo

Agenda

Page 3: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

A bit about me

• IT Pro and developer for the past 16 years

• Chief Architect from miiiCasa Inc. • Experienced in Serverless and ECS

across multiple AWS regions • AWS all-5 certificates holder

Page 4: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

What is Lambda, actually?

What is Lambda

Page 5: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

homegrown variant of Linux container

with high speed of work routing and placement

What is Lambda

Page 6: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

single/multiple instancesmonolithic applications

What is Lambda

Page 7: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

https://twitter.com/adrianco/status/736553530689998848

What is Lambda

Page 8: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

API

FunctionAPI

Function

API

Function

API

Function

API

Function

API

Function

API

Function

[micro] Application design in the cloud

Page 9: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

• Startup and termination • Freeze and thaw cycle

Cold Start Terminate Freeze

Thaw

Handler

Understanding Container Reuse

Page 10: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

Challenges in Serverless Development

Challenges

Page 11: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

Local development and testing?

Securing your credentials?

Performance tuning and optimization?

Continuous delivery?

Language constraints?

Challenges

Page 12: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

Continuous Delivery

Continuous Delivery

Page 13: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

local dev/test

end-to-end test

update alias

Fail

publish

Serverless Development Pipelines

Log and Monitor

SlackAnalytics

Page 14: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

Environment Pinning with API Gateway and Lambda

Continuous Delivery

Page 15: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

AWS Lambda CD Relevant Features

Page 16: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

Function Versions

• Immutable versions of functions • Per version configuration • Per version cloudwatch metrics • Cloudwatch Logs with version

attribute • Export/Download the codes

Page 17: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

Update Function Code

• update function with local zip bundle • always update $LATEST version of

your lambda function

Page 18: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

Publish Version

• Publishes a version of your function from the current snapshot of $LATEST.

Page 19: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

Publish Version

• update the function version to which the alias points.

Page 20: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

Update Alias

$LATEST(95) STABLE TESTING

94 V

93 V

92

Page 21: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

Update Alias

$LATEST(95) STABLE TESTING

94 V V

93

92

Page 22: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

API Gateway CD Relevant Features

Page 23: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

API Stages

Page 24: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

API Gateway stage variables

Page 25: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

API Gateway stage variables

Page 26: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

Access stage variables in Lambda

Page 27: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

Environment Pinning Table

API Gateway Lambda Custom Domain

/prod/Resources ReosurceManager:stable https://api.example.com

/dev/Resources ReosurceManager:$LATEST https://dev.example.com

/qa/Resources ReosurceManager:qa https://qa.example.com

Page 28: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

Continuous Delivery Scenarios

Page 29: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

AWS CodeCommit and CodePipeline with Lambda

3rd Party Integrations

Continuous Delivery Scenarios

Page 30: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

source

S3/Github

publish-to-Dev

test-Dev

release-Dev

AWS Pipeline Integration

PubNewVersion

TestNewVersion

RelNewVersion

AddItem

UpdateFunctionCode

AddItemTest

AddItemApiTest

InvokeInvoke

InvokeInvoke

Invoke

Invoke

Invoke

Page 31: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

source

Local Laptop

3rd party integration

AddItem

UpdateFunctionCode

AddItemApiTest

Invoke

InvokeInvoke

Runscope end-to-end testcallback

Page 32: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

Best Practices

Page 33: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

Securing your credentials

Leverage the nature of container reuse

Prewarm your Lambda functions

Best Practices

Page 34: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

NEVER hardcode your credentials

Page 35: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

Use CredentialProviderChain in AWS-SDK

https://gist.github.com/pahud/836481ae759147d3f493d3ead1f5406a

Page 36: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

Define in API Gateway stage variables

Encrypt and save in AWS KMS

Save in S3 with Server-Side Encryption

For 3rd Party API Credentials

Page 37: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

Leverage Container Reuse

Page 38: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

• Startup and termination • Freeze and thaw cycle

Cold Start Terminate Freeze

Thaw

Handler

Understanding Container Reuse

Page 39: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

Show me the Codes!

Page 40: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

Page 41: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

Page 42: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

Cloudwatch Events Integration

Page 43: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

CloudWatch Events scheduled invocation

Page 44: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

chalice - python serverless microframework by AWS

claudiajs - Deploy Node.js microservices to AWS easily

serverless - Serverless Framework

apex - Build, deploy, and manage AWS Lambda functions with ease (with Go support!)

lambCI - Serverless continuous integration

Resources and Takeaways

Page 45: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

Demo

Page 46: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

What’s next?A Hands-on Workshop on AWS Infrastructure Services

Date: Sep 29, 2016

AWS 10-Minute Tutorials “Hello, World!” technical documents to help you get hands-on with AWS.

Page 47: 管理程式對AWS LAMBDA持續交付

AWS Cloud Kata for Start-Ups and Developers

Thank You!

@pahudnet