如何将常量json数据传递和检索到lambda函数

sak*_*zai 10 amazon-web-services amazon-cloudwatch aws-lambda

在此输入图像描述

我有定义的lambda函数,如:

def lambda_handler(event, context):

   #get constant json argument passed from cloudwatch event rule

   ...
Run Code Online (Sandbox Code Playgroud)

获取Target/Configure Input/Constant(Json文本)中定义的值的方法是什么.

小智 18

当我在AWS文档中读到时,json以dict类型传递给python.然后我只需调用这样的值:

通过json:

{"type": "daily", "retention": 7}
Run Code Online (Sandbox Code Playgroud)

然后在你的处理程序:

def lambda_handler(event, context):
    type = event["type"]
    rententionDay = event["retention"]
    ...
Run Code Online (Sandbox Code Playgroud)

使用此我能够为所有ebs卷制作自动化快照.希望它有所帮助.