How to pass and retrieve constant json data to lambda function

后端 未结 2 2180
误落风尘
误落风尘 2021-02-20 06:33

I have lambda function defined sth like :

def lambda_handler(event, context):

   #get constant json argument passed from cloudwatch event rule

   ...
         


        
2条回答
  •  清歌不尽
    2021-02-20 07:17

    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.

提交回复
热议问题