0

I'm new to AWS and here is the task I'm trying to solve. SQS queue is set up and from time to time new messages are coming to it. I want to set up Lambda and retrieve those messages and perform some business logic on the content of that messages.

Searching across AWS site and Internet in general I understood that SQS itself can't be a trigger for Lambda, hence I need to set up Cloud Watch that will trigger Lambda by schedule (every minute for example). Here is code example from aws github how to consume a message.

So far so good. Now, when creating Lambda itself, I need to specify the input type to implement RequestHandler interface:

public interface RequestHandler<I, O> { O handleRequest(I var1, Context var2); 

}

But if my Lambda is not expecting any input, it will go to SQS on its own and pull the messages does it make any sense to have input? Can I leave it void or even use some other method signature at all (of course not implementing that interface in this case)?

1 Answer 1

0

Here your Lambda will get a reference to the cloudwatch trigger.

You might not be interested in that but there can be instances where the Lambda wants to know the trigger details even if the trigger is a cloudwatch alarm

The following is an example event:

{ "version": "0", "id": "53dc4d37-cffa-4f76-80c9-8b7d4a4d2eaa", "detail-type": "Scheduled Event", "source": "aws.events", "account": "123456789012", "time": "2015-10-08T16:53:06Z", "region": "us-east-1", "resources": [ "arn:aws:events:us-east-1:123456789012:rule/my-scheduled-rule" ], "detail": {} }

Sign up to request clarification or add additional context in comments.

3 Comments

So, I should expect something line ScheduledEvent as an input for my Lambda?
Yes. In case it's triggered via cloudwatch
I would be really helpful to get the trigger details as the input, for example; the cron definition.. unfortunately it seems to require an api call.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.