标签:
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