How to pass and retrieve constant json data to lambda function

左心房为你撑大大i 提交于 2019-12-05 01:33:18
Dominic Nguyen

As I read in AWS documents, json passed to python as dict type. And then I simply call the value like this:

passed json:

{"type": "daily", "retention": 7}

Then in your handler:

def lambda_handler(event, context):
    type = event["type"]
    rententionDay = event["retention"]
    ...

Use this I was able to make an automation snapshot for all ebs volumes. Hope it help.

This is based on NodeJS, but it should be the same for Python. The Constant under Input is a simple JSON encoded object, which can then be accessed using the event variable.

Input

{ "config": "uk" }

Lambda

console.log(event.config)

Found this entry as one of the top Google results, so hopefully this will help someone else.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!