The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

532789 (7) [Avatar] Offline
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 (73) [Avatar] Offline
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 (7) [Avatar] Offline
still no luck smilie I literally copy and paste from [here]( to check if it was makeing a typo and still no luck. Any chance you take a look at it?
Yan Cui (73) [Avatar] Offline
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 (7) [Avatar] Offline
Yan Cui (73) [Avatar] Offline
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\":\"\"},\"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 (7) [Avatar] Offline
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).