如何传递和检索常量json数据到lambda函数 [英] How to pass and retrieve constant json data to lambda function

查看:105
本文介绍了如何传递和检索常量json数据到lambda函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经定义了lambda函数,例如:

I have lambda function defined sth like :

def lambda_handler(event, context):

   #get constant json argument passed from cloudwatch event rule

   ...

如何获取在Target / Configure Input / Constant(Json文本)中定义的值。

What is the way to get the values defined in Target/Configure Input /Constant(Json text).

推荐答案

在我阅读AWS文档时,json作为dict类型传递给python。然后我简单地这样调用值:

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

通过json:

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

然后在处理程序中:

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

使用此功能,我能够所有ebs卷的自动化快照。
希望有帮助。

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

这篇关于如何传递和检索常量json数据到lambda函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆