I have a lambda which gets triggered by lambda cloudwatch rule. This is the cloudwatch rule created via cloudformation
Resources:
CloudWatchRule:
Type: AWS::Events::Rule
Properties:
Name: !Sub CloudWatchRule-${Stage}
Description: "Scheduled event to fetch keys for score generation every hour"
ScheduleExpression: "rate(2 minutes)"
Targets:
- Arn:
Fn::GetAtt: [FetcherLambda, Arn]
Id: "CloudWatchEvent"
Input: '{"hours": 3}'
CloudWatchRulePermission:
Type: AWS::Lambda::Permission
Properties:
FunctionName:
Ref: FetcherLambda
Action: "lambda:InvokeFunction"
Principal: "events.amazonaws.com"
SourceArn:
Fn::GetAtt: [CloudWatchRule, Arn]
I can see in the console that the input is there in Constant(Json) field.
But in the handler, when I am logging I am getting empty event,
public Void handleRequest(final ScheduledEvent scheduledEvent, final Context context) {
log.info("Received event: {}", scheduledEvent);
return null;
}
I am getting a log as
Received event: {}
Am I missing something or is there anything else needed to get the input here