AMAZON and Lambda(1)Lambda Introduction

AMAZON and Lambda(1)Lambda Introduction

Introduction Of Lambda
Lambda function: custom codes and dependent libraries
Event source: AWS service, for example, SNS, custom service which triggers my function and executes its logic.
Downstream resources: AWS service, DynamoDB tables or Amazon S3 bucket
Log streams:
AWS SAM: Serveless Application Model

On my Local Machine I already have AWS Cli installed
>aws --version
aws-cli/1.10.16 Python/2.7.13 Darwin/17.3.0 botocore/1.8.15

Try on lambda command to list the functions
>aws lambda list-functions
{
"Functions": [
{
"TracingConfig": {
"Mode": "PassThrough"
},

Install SAM Local
Have Docker on Local first, I am using MAC
>docker --version
Docker version 18.02.0-ce-rc1, build 5e1d90a

https://github.com/lambci/docker-lambda

--rm, the container is removed when it exits or when the daemon exits, whichever happens first.
>docker run --rm -v "$PWD":/var/task lambci/lambda

Installing SAM Local
>npm install -g aws-sam-local

>sam --version
sam version 0.2.6

Create a Simple Lambda Function and Explore the Console
Author from Scratch or Blueprints after “Create Function”

Name: sqsEventConsumer
Runtime: Node.js 6.10
I choose create a new role and SQS Poller Permission to future usage.

After create the function, it will show up the next page.
In the Node.JS 6.10 example, it demos like
exports.handler = (event, context, callback) => {
// TODO implement
callback(null, 'Hello from Lambda');
};

Handler shows: index.handler, that is the file name and function name
Concurrent Execution Limit
http://docs.amazonaws.cn/en_us/lambda/latest/dg/concurrent-executions.html#per-function-concurrency

Click “Test”, then we can test the lambda.

Best practices
http://docs.amazonaws.cn/en_us/lambda/latest/dg/best-practices.html

Lambda Env
http://docs.amazonaws.cn/en_us/lambda/latest/dg/current-supported-versions.html

The demo hello world can be
exports.handler = (event, context, callback) => {
var name = event.name;
callback(null, name + ' Hello from Lambda');
};

The test data is as follow:
{
"name": "test"
}

The result is
"test Hello from Lambda"


References:
https://docs.aws.amazon.com/zh_cn/lambda/latest/dg/use-cases.html
http://docs.amazonaws.cn/lambda/latest/dg/getting-started.html
http://docs.amazonaws.cn/en_us/lambda/latest/dg/getting-started-create-function.html
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值