码迷,mamicode.com
首页 > Windows程序 > 详细

[AWS Lambda] Use AWS Lambda and API Gateway to return data

时间:2016-05-08 16:48:59      阅读:290      评论:0      收藏:0      [点我收藏+]

标签:

In this lesson, you will learn how to create a simple AWS Lambda function to submit a name via an API Gateway and return a resume for that person. At the end of the lesson, you will be able to create a Lambda function, and API Gateway, and understand how to submit data via the API Gateway that will be accessible via the Lambda function

 

1. Go to Lambda, create a new function. You can skip the blueprint.

2. Enter the function name: "getResume" and code:

exports.handler = function(event, context){
    var resume = {};
    resume.firstName = event.firstName;
    resume.lastName = event.lastName;
    
    resume.workHistory = [
        {
            companyName: "Make Helsinki",
            period: 1
        },
        {
            companyName: "Tecnotree Oy",
            period: 1
        }
    ];
    
    context.succeed(resume);
}

event: Hold the param you send in.

context: call succeed() function to return the data.

 

技术分享

 

3. You can test your function:

技术分享

 

4. Then go to the AWS dashboard, click API Getway, create a new gateway:

技术分享

 

5. Create a post request which intergate with Lambad function we just created:

技术分享

 

6. You can test the api.

技术分享

7. Deploy API:
技术分享

 

8. Finally, you can use Postman, to test the api.

 

[AWS Lambda] Use AWS Lambda and API Gateway to return data

标签:

原文地址:http://www.cnblogs.com/Answer1215/p/5470843.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!