Reading Event Parameters AWS lambda

南笙酒味 提交于 2019-12-02 04:31:08

AWS Lambda automatically monitors Lambda functions on your behalf, reporting metrics through Amazon CloudWatch. You could check it (go to monitoring Tab on lambda function, then click on 'View on CloudWatch'). You will see that event has 'greeter' parameter only ( console.log('Received event:', JSON.stringify(event, null, 2)); prints to log as well).

It happened because you haven't mapped every one of the parameters on your Gateway API. You could do it in 'Integration Request'/'Mapping Template' of your method's properties.

Check out how to map it in API Gateway Mapping Template Reference article, in the 'Accessing the $input Variable' section.

Your template should be something like next example:

{
    "greeter": "$input.params('greeter')",
    "greeter1": "$input.params('greeter1')",
    "Data": $input.json('$')
}
  • $input.params - map data from param
  • $input.json('$') - map data from request body (if it is post or put)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!