532789 (6) [Avatar] Offline
#1
following the auto-create-api-alarms lesson, I'm noticing the lambda is never triggered, according to the instructions, it waits for the CreateDeloyment event to be triggered after then serverless deployment, but looking at the logs (there are no logs) it looks like for some reason it is not happening, I've already tried copying and pasting for the github repo and still the same issue.

any idea?
Yan Cui (68) [Avatar] Offline
#2
It can sometimes take a few mins (up to 10 mins in my experience) to trigger, and another thing to look out for, is make sure that your CloudTrail is configured to capture everything.
532789 (6) [Avatar] Offline
#3
still no luck smilie I literally copy and paste from [here](https://github.com/theburningmonk/manning-aws-lambda-in-motion/blob/master/functions/create-alarms.js) to check if it was makeing a typo and still no luck. Any chance you take a look at it?
Yan Cui (68) [Avatar] Offline
#4
Can you show me what your serverless.yml looks like? Alternatively if you can put your code on github I can take a look as well.
532789 (6) [Avatar] Offline
#5
Yan Cui (68) [Avatar] Offline
#6
Your serverless.yml looks fine, can you go to the Lambda console, go to the auto-create-api-alarms function, click on the CloudWatch Events trigger, head to the bottom and make sure that "Enabled" toggle is ON.

If that's the case, then I think the problem is likely at the CloudTrail layer or to do with permissions.

Go to CloudTrail console, look at the trail you created, and make sure that under the "Management events" section it's capturing all read/write events.

To see if the right permission is issued to CloudWatch Events to trigger the function, use the AWS CLI tool and run "aws lambda get-policy --function-name big-mouth-dev-auto-create-api-alarms" and make sure you see something like this:

{
    "Policy": "{\"Version\":\"2012-10-17\",\"Id\":\"default\",\"Statement\":[{\"Sid\":\"big-mouth-dev-AutoDashcreateDashapiDashalarmsLambdaPermissionEventsRuleCloudWatchEvent-2Z55H94WLAQH\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"events.amazonaws.com\"},\"Action\":\"lambda:InvokeFunction\",\"Resource\":\"arn:aws:lambda:us-east-1:374852340823:function:big-mouth-dev-auto-create-api-alarms\",\"Condition\":{\"ArnLike\":{\"AWS:SourceArn\":\"arn:aws:events:us-east-1:374852340823:rule/big-mouth-dev-AutoDashcreateDashapiDashalarmsEvent-VM5DP0L1AL2V\"}}}]}"
}


The serverless framework should have generated this policy for you during deployment, but let's double check.
532789 (6) [Avatar] Offline
#7
Thanks for the response, I went to through the video a few more times and still the problem persist, but here is the thing, from your suggestion, I was able to validate the the cloudwatch event on the lambda fn is enable and the policy is created.

I went to my Trails and I dont have any created, did we create it manually at some point? so I created one and attach all my lambdas, deployed again, after the events are trigger on cloudtrail CreateDeployment it also created a DeleteDeployment a few seconds later and still not updates smilie. I check the s3 bucket that I created for my trails and it logs, I have logs from today in here.

Also I went to the cloudwatch log for the fn and it has never been trigger.

My user has administrator permissions (in case it matters).