aws-samples / aws-lambda-ddns-function

Dynamically create Route 53 resource records using CloudWatch Events and Lambda
Apache License 2.0
236 stars 116 forks source link

Working but showing an error #7

Closed ghost closed 7 years ago

ghost commented 7 years ago

The Route53 entries are being created and removed successful, but there are errors in the logs. This happens multiple times per invocation.

'Item': KeyError Traceback (most recent call last): File "/var/task/lambda_function.py", line 80, in lambda_handler instance = instance['Item']['InstanceAttributes'] KeyError: 'Item'

'Item': KeyError
Traceback (most recent call last):
File "/var/task/lambda_function.py", line 80, in lambda_handler
instance = instance['Item']['InstanceAttributes']
KeyError: 'Item'
jicowan commented 7 years ago

You may be getting an error because the record for the instances does not exist in the DDB table. The function should not retrieve the instance attributes from the table unless you're terminating or stopping it. It's as if the else statement is being ignored.

rbmandadapu commented 7 years ago

'detail': KeyError Traceback (most recent call last): File "/var/task/Cloudtraillambdamonitor.py", line 40, in lambda_handler eventname = event['detail']['eventName'] KeyError: 'detail'

Someone help me with this, I got this error while running Lambda function to monitor CloudTrail evnets.

jicowan commented 7 years ago

Did you configure the CloudWatch Event? Which EC2 events are you listening for?


From: R B notifications@github.com Sent: Friday, July 21, 2017 10:47:32 AM To: awslabs/aws-lambda-ddns-function Cc: Jeremy Cowan; State change Subject: Re: [awslabs/aws-lambda-ddns-function] Working but showing an error (#7)

'detail': KeyError Traceback (most recent call last): File "/var/task/Cloudtraillambdamonitor.py", line 40, in lambda_handler eventname = event['detail']['eventName'] KeyError: 'detail'

Someone help me with this, I got this error while running Lambda function to monitor CloudTrail evnets.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://github.com/awslabs/aws-lambda-ddns-function/issues/7#issuecomment-317036982, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AIWEq33a_jIQVy1byrjQ6ezF8BSTsRB9ks5sQMgUgaJpZM4Ky5bn.

rbmandadapu commented 7 years ago

Yes, I did, I'm using this service to monitor Cloud Trail events.

https://aws.amazon.com/blogs/mt/monitor-changes-and-auto-enable-logging-in-aws-cloudtrail/?sc_channel=sm&sc_campaign=AWS%20Blog&sc_publisher=FACEBOOK&sc_country=Global&sc_geo=GLOBAL&sc_outcome=awareness&sc_content=mt_blog&sc_category=AWS_CloudTrail&linkId=39869681

I'm following this link to setup this service, Using same code they provided.

jicowan commented 7 years ago

The error you getting indicates that the json payload does not have a 'detail' node. What events are you sending to the function?


From: R B notifications@github.com Sent: Friday, July 21, 2017 10:47:32 AM To: awslabs/aws-lambda-ddns-function Cc: Jeremy Cowan; State change Subject: Re: [awslabs/aws-lambda-ddns-function] Working but showing an error (#7)

'detail': KeyError Traceback (most recent call last): File "/var/task/Cloudtraillambdamonitor.py", line 40, in lambda_handler eventname = event['detail']['eventName'] KeyError: 'detail'

Someone help me with this, I got this error while running Lambda function to monitor CloudTrail evnets.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://github.com/awslabs/aws-lambda-ddns-function/issues/7#issuecomment-317036982, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AIWEq33a_jIQVy1byrjQ6ezF8BSTsRB9ks5sQMgUgaJpZM4Ky5bn.

rbmandadapu commented 7 years ago

Below are the events that I want to track,

“StopLogging” “StartLogging” “UpdateTrail” “DeleteTrail” “CreateTrail” “RemoveTags” “AddTags”

When I use CF to run, I got the error that I mentioned, But When I configure it manually I'm getting error in Lambda console like this " Unable to import module 'lambda_function': No module named lambda_function' "

jicowan commented 7 years ago

I think you posted an issue to the wrong repo. This repo is for creating entries in route 53 as EC2 instances are created.


From: R B notifications@github.com Sent: Friday, July 21, 2017 1:51:10 PM To: awslabs/aws-lambda-ddns-function Cc: Jeremy Cowan; State change Subject: Re: [awslabs/aws-lambda-ddns-function] Working but showing an error (#7)

Below are the events that I want to track,

“StopLogging” “StartLogging” “UpdateTrail” “DeleteTrail” “CreateTrail” “RemoveTags” “AddTags”

When I use CF to run, I got the error that I mentioned, But When I configure it manually I'm getting error in Lambda console like this " Unable to import module 'lambda_function': No module named lambda_function' "

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://github.com/awslabs/aws-lambda-ddns-function/issues/7#issuecomment-317083336, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AIWEq8_NYF1bxSVeWjC4q7-_jvWMAxaEks5sQPMegaJpZM4Ky5bn.

rbmandadapu commented 7 years ago

Got it. I was checking, I found this repo. It looks like a similar issue. anyway, thanks though. Could you please post me the correct repo. That would be helpful.

jicowan commented 7 years ago

What repo were you looking for? What repo did you pull from Github?


From: R B notifications@github.com Sent: Friday, July 21, 2017 1:57:20 PM To: awslabs/aws-lambda-ddns-function Cc: Jeremy Cowan; State change Subject: Re: [awslabs/aws-lambda-ddns-function] Working but showing an error (#7)

Got it. I was checking, I found this repo. It looks like a similar issue. anyway, thanks though. Could you please post me the correct repo. That would be helpful.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://github.com/awslabs/aws-lambda-ddns-function/issues/7#issuecomment-317084848, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AIWEq5ebZkFCRbjiBW9e1oujTTo7cxDRks5sQPSQgaJpZM4Ky5bn.

rbmandadapu commented 7 years ago

I was looking for Lambda and CloudTrail Repo, But I didn;t find anything helpful here, everyone is saying that it is a wrong repo. I guess I can take this issue to Amazon Support.

jicowan commented 7 years ago

Have you tried posting a comment on the blog post yet?