`
sillycat
  • 浏览: 2543180 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

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


分享到:
评论

相关推荐

    Serverless Architectures with AWS-Packt Publishing (December 2018).pdf

    introduction to the serverless model and helps you get started with AWS and AWS Lambda. You'll also get to grips with other capabilities of the AWS serverless platform and see how AWS supports ...

    Serverless Applications with Node.js

    Along the way, you'll practice your new skills by building a working chatbot and a voice assistant with Amazon Alexa. You'll also discover techniques for migrating existing apps to a serverless ...

    Real-time.Big.Data.Analytics.17843

    Process and stream data with Amazon Kinesis and Elastic MapReduce Perform interactive and exploratory data analytics using Spark SQL Develop common enterprise architectures/applications for real-time ...

    AWS(亚马逊)云解决方案架构师面试实践过程作业全英文作业2(Assignment#2).pdf

    1. **Introduction** 面试实践过程的作业可能涉及介绍一个实际或模拟的业务场景,要求候选人根据给定的信息来设计一个满足特定需求的云架构。这可能涵盖技术、成本效益分析和最佳实践等方面。 2. **Assumption of...

    AWS Cloud Practitioner Essential Student Guide Version 3.3.0

    《AWS Cloud Practitioner Essential Student Guide Version 3.3.0》是针对AWS云从业者基础学习的一份详实指南,涵盖了亚马逊网络服务(Amazon Web Services,简称AWS)的关键概念和技术。以下是对各模块主要内容的...

    Azure上无服务器功能简介

    在提供的文件中,“An-Introduction-to-Serverless-Functions-on-Azure.pdf”可能是详细阐述Azure Functions的教程,包括创建、部署和管理函数的步骤。而“master.zip”可能包含一个示例项目,其中包含了用于地理...

Global site tag (gtag.js) - Google Analytics