Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS lambda unable to create a scheduled event source

Unable to create a recurring schedule for lambda.

What I did:

1) Created the function and successfully tested it.

2) Went to event source section in the AWS mgmt console.

3) clicked on add event source.

4) with default settings of rate(5 minutes) clicked on submit.

Got the error:

There was an error creating the event source mapping: Could not create scheduled-event event source

I went through the docs and ran this statement via AWS CLI:

aws lambda add-permission --statement-id Allow-scheduled-events --action lambda:InvokeFunction --principal events.amazonaws.com --function-name function:myfunction

The above statement went through successfully, I tried running it again and it said the permission already exists confirming that it ran.

I tried adding the schedule again but got the same error.

Am i supposed to change the role or something? Can't anything else in the docs. The lambda is running with basic lambda execution role.

UPDATE

I temporarily gave the role under which the Lambda is executing admin access, still the same error.

Workaround

FYI... for people facing this problem, I could achieve the same result by going to cloudwatch and adding an event targeting lambda from there... same thing, that still does not answer this question though. I cant imagine that AWS console has such a gaping bug that they aren't doing anything about.

like image 666
Sumit Maingi Avatar asked Nov 09 '22 14:11

Sumit Maingi


1 Answers

In my case my Lambda and S3 were not in the same region. I found out by, instead of adding the trigger on the Lambda, adding the event from s3.

like image 115
dandoen Avatar answered Nov 14 '22 20:11

dandoen