AWS Lambda - CloudWatch Event type

后端 未结 3 497
野的像风
野的像风 2021-02-05 03:07

When writing an AWS Java Lambda function that\'s triggered by Cloudwatch scheduled events, which event object gets passed to the Lambda handler function?

For example, fo

3条回答
  •  梦谈多话
    2021-02-05 03:17

    Unfortunately there is no specific class for this type of events.

    But you can freely create your own POJOs and specify them as class of event parameter. For instance, CloudWatchEvent can be described as:

    public class CloudWatchEvent {
    
        private String version;
        private String id;
        private String detailType;
        private String source;
        private String account;
        private Date time;
        private String region;
        private List resources;
        ...   
        // getters and setters
    }
    

    AWS Lambda engine automatically tries to serialize input into the object of the given class.

    To know the structure you can specify type "Map" and printout it to log:

      public void eventHandler(Map event, Context context) {
            log.debug(event); // or System.out....
      }
    

提交回复
热议问题