39
© 2015, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Tara E. Walker Technical Evangelist Amazon Web Services An Introduction to AWS Lambda Serverless Cloud

A Walk in the Cloud with AWS Lambda

Embed Size (px)

Citation preview

Page 1: A Walk in the Cloud with AWS Lambda

© 2015, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Tara E. Walker

Technical Evangelist

Amazon Web Services

An Introduction to AWS Lambda

Serverless Cloud

Page 2: A Walk in the Cloud with AWS Lambda

AWS Compute offerings

LambdaServerless compute

platform for stateless

code execution in

response to Triggers

ECSContainer

management service

for running Docker on

a managed cluster of

EC2

EC2Virtual servers

in the Cloud

Page 3: A Walk in the Cloud with AWS Lambda

AWS Lambda Overview

A compute service where you

don’t have to think about:

• Servers

• Being over/under capacity

• Deployments

• Scaling and fault tolerance

• OS or language updates

• Metrics and logging

…but where you can easily

• Bring your own code…

even native libraries

• Run code in parallel

• Create backends, event

handlers, and data

processing systems

• Never pay for idle!

Page 4: A Walk in the Cloud with AWS Lambda

AWS Lambda – Benefits

EVENT-DRIVEN SCALESERVERLESS SUBSECOND BILLING

Page 5: A Walk in the Cloud with AWS Lambda

AWS Lambda – How It Works

DEPLOYMENT

AUTHORING

MONITORING & LOGGING

STATELESS

Page 6: A Walk in the Cloud with AWS Lambda

AWS Services Integrated with AWS Lambda

Amazon

S3

Amazon

DynamoDB

Amazon

Kinesis

November 13, 2014

Page 7: A Walk in the Cloud with AWS Lambda

AWS Services Integrated with AWS Lambda

Amazon

S3

Amazon

DynamoDB

Amazon

Kinesis

AWS

CloudTrail

Amazon

CloudWatch

Logs

AWS

CloudFormation

Amazon

SNS

Amazon

SWF

Amazon

SES

Amazon

API Gateway

Amazon

Cognito

Page 8: A Walk in the Cloud with AWS Lambda

AWS Lambda – Partner Blueprints

Page 9: A Walk in the Cloud with AWS Lambda

Languages and Features

re:Invent 2014Preview Launch

April 2015GA

Summer 2015 re:Invent 2015

• Node.js

• Event handlers

• CORS

• Mobile

Backends

• Sync calls

• Resource

policies

• Java

• Amazon S3

uploads

• Blueprints

• 1.5 GB

• Tokyo region

• Alexa Skills

• …and…

Page 10: A Walk in the Cloud with AWS Lambda

In case you missed it…

Page 11: A Walk in the Cloud with AWS Lambda

Amazon Simple Email Service Inbound Rules

// Spam check

if (sesNotification.receipt.spamVerdict.status === 'FAIL‘ ||

sesNotification.receipt.virusVerdict.status === 'FAIL')

console.log('Dropping spam');

Page 12: A Walk in the Cloud with AWS Lambda

Amazon CloudWatch Logs Processing

Scan, audit, or index log entries in near real time

AWS LambdaAmazon CloudWatch

Logs

Amazon

DynamoDB

Amazon S3

Amazon

Redshift

Page 13: A Walk in the Cloud with AWS Lambda

Lambda update: 5 new features announced

earlier this month at re:Invent 2015

1. Python functions

2. Increased function duration

3. Function versioning & aliasing

4. Scheduled functions (Cron)

5. Accessing Resources in a VPC From a Lambda Function

[coming soon]

Details at: https://aws.amazon.com/blogs/aws/aws-lambda-update-

python-vpc-increased-function-duration-scheduling-and-more/

Page 14: A Walk in the Cloud with AWS Lambda

New Feature: Python 2.7

Page 15: A Walk in the Cloud with AWS Lambda

Demo:

Python 2.7 - Hello World

Page 16: A Walk in the Cloud with AWS Lambda

Python 2.7 Support in AWS Lambda

• Available today in

• All SDKs (including mobile SDKs)

• AWS CLI

• Lambda console (including interactive editing)

• Includes

• Version 1.1.3 of boto3 (AWS Python SDK)

• Documentation and walkthroughs

• Console blueprints

Page 17: A Walk in the Cloud with AWS Lambda

New Feature: Longer-running Functions

Page 18: A Walk in the Cloud with AWS Lambda

Longer-running AWS Lambda Functions

• Run functions for up to 5 minutes

• Available today in the following SDKs

• Python (boto3)

• Java

• Node.js

• PHP

• AWS Mobile SDK for Android

• AWS Mobile SDK for iOS

Page 19: A Walk in the Cloud with AWS Lambda

Resource Sizing

• AWS Lambda offers 23 “power levels”

• Higher levels offer more memory and more CPU power• 128 MB, lowest CPU power

• 1.5 GB, highest CPU power

• Higher power levels == lower latency for CPU-bound and bursty tasks

• Compute price scales with the power level

• Duration ranging from 100ms to 5 minutes

• Free Tier: 1M free requests and 400,000 GB-s / month

Page 20: A Walk in the Cloud with AWS Lambda

New Feature: Scheduled Functions

Page 21: A Walk in the Cloud with AWS Lambda

Demo:

Scheduled Function - Canary

Page 22: A Walk in the Cloud with AWS Lambda

Scheduled AWS Lambda Functions

• Available today in the Lambda console

• Schedule functions at a specific time or recurring

• Accepts standard cron syntax

• 5 minute granularity

• You can get sub-second granularity using a Lambda function

• Easily poll Amazon SQS or other data sources!

• Coming later in 2015: CLI, SDK support

Page 23: A Walk in the Cloud with AWS Lambda

New Feature: Versioning

Page 24: A Walk in the Cloud with AWS Lambda

Versioning: Development

Developing in AWS Lambda stays simple:

• Upload code

• Make changes any time

• Last update wins

exports.handler =

function(event,context)

{context.succeed(“bye”);}

exports.handler =

function(event,context)

{context.succeed(“hi”);}

Page 25: A Walk in the Cloud with AWS Lambda

Versioning: Publishing

Publish new versions from development at any time:

• “Copies” dev version to a numbered version

• Published versions are read-only (including configuration)

• Simple, integer counter per function

exports.handler =

function(event,context)

{context.succeed(“bye”);}

exports.handler =

function(event,context)

{context.succeed(“hi”);}1

2Versions

Page 26: A Walk in the Cloud with AWS Lambda

Versioning: Calling Lambda Functions

Development version:

FunctionName (or)

FunctionName:$LATEST

Specific version:

FunctionName:1

FunctionName:2

Named version:

FunctionName:production

FunctionName:v1_2_3_4

Page 27: A Walk in the Cloud with AWS Lambda

Versioning: Aliases

Create named aliases to any version:

• Allows function owner to map ARNs to code

• Can be updated without changing clients

exports.handler =

function(event,context)

{context.succeed(“bye”);}

exports.handler =

function(event,context)

{context.succeed(“hi”);}prod

devAliases

Page 28: A Walk in the Cloud with AWS Lambda

Amazon API Gateway:

Version your APIs

/prod/my_url_endpoint

MyFunction:prod_rel

Versioning APIs and Code

MyFunction:prod_rel

Function:3

{your code}

AWS Lambda:

Version your code

Page 29: A Walk in the Cloud with AWS Lambda

New Feature: IoT Backends

Page 30: A Walk in the Cloud with AWS Lambda

AWS IoT + AWS Lambda

Page 31: A Walk in the Cloud with AWS Lambda

Sneak Peek: VPC Access

Page 32: A Walk in the Cloud with AWS Lambda

Sneak Peek: Accessing Resources in a VPC

From a Lambda Function [Coming soon]

Description: Access resources behind a VPC from inside

Lambda functions

Benefit: You will soon be able to access resources in a

private IP range in your VPC, including EC2, ELB, RDS,

ElastiCache and Redshift

How it works: When creating Lambda functions, you will be

able to select the VPC subnets and security groups, and the

Lambda function executions can then access private

endpoints in that VPC IP range

Page 33: A Walk in the Cloud with AWS Lambda

AWS Lambda VPC Access

• Select the functions to run in your VPC

• Select subnets and security groups to use

• Your Lambda function can access the private resources

you choose:

• Amazon Elasticache

• Amazon RDS

• Private EC2 endpoints

• Any other resources in your VPC

• Launching later this year in all AWS Lambda regions

Page 34: A Walk in the Cloud with AWS Lambda
Page 35: A Walk in the Cloud with AWS Lambda

We’ve been busy.

Now it’s your turn.

Page 36: A Walk in the Cloud with AWS Lambda

Go to the AWS Lambda console,

create a function, and run it.(The first million invokes are on us!)

Page 37: A Walk in the Cloud with AWS Lambda

Congrats, you’re a Lambda

function expert! Add an event

source or an HTTP endpoint.

Page 38: A Walk in the Cloud with AWS Lambda

Build a mobile, voice, or IoT

backend with a few lines of

code.

Page 39: A Walk in the Cloud with AWS Lambda

Thank you!

Follow me on Twitter @taraw

Follow AWS Lambda!

aws.amazon.com/blogs/compute

aws.amazon.com/lambda

AWS Lambda Forum