Giter Club home page Giter Club logo

Comments (15)

davidrobertson avatar davidrobertson commented on June 29, 2024 2

I figured it out.

There's a 'sleep 60' in there, but the lambda app has a 30 second timeout. I raised the the lambda app timeout to 90 seconds, and everything is working fine now.

Thanks again...

from aws-lambda-ddns-function.

jicowan avatar jicowan commented on June 29, 2024

David, when do you get this error? When you terminate an instance? Can you send me the item for this instance in the DDB table?

from aws-lambda-ddns-function.

davidrobertson avatar davidrobertson commented on June 29, 2024

I get the error when I try to start, stop, or terminate an instance. DynamoDB table appears to be empty.

from aws-lambda-ddns-function.

davidrobertson avatar davidrobertson commented on June 29, 2024

Looks like it's timing out, which I didn't notice before. Here's everything in the log:

START RequestId: c8bc718c-0f51-11e7-89e7-91fb6821101a Version: $LATEST
DynamoDB table already exists
END RequestId: c8bc718c-0f51-11e7-89e7-91fb6821101a
REPORT RequestId: c8bc718c-0f51-11e7-89e7-91fb6821101a Duration: 30002.30 ms Billed Duration: 30000 ms Memory Size: 128 MB Max Memory Used: 38 MB
2017-03-22T22:53:41.791Z c8bc718c-0f51-11e7-89e7-91fb6821101a Task timed out after 30.00 seconds

from aws-lambda-ddns-function.

jicowan avatar jicowan commented on June 29, 2024

Thanks David. Can you add the following to line 25:
print event
this will output the full event to the log group for the function. I'd like to see what is being passed to the function.

from aws-lambda-ddns-function.

davidrobertson avatar davidrobertson commented on June 29, 2024

After adding 'print event' to line 25, nothing new was being logged. After realizing the DDB table is being created (just left empty), I've moved 'print event' to line 23. This is what's logged now:

{u'account': u'xxx', u'region': u'us-east-1', u'detail': {u'state': u'running', u'instance-id': u'i-0698e7d5720e30809'}, u'detail-type': u'EC2 Instance State-change Notification', u'source': u'aws.ec2', u'version': u'0', u'time': u'2017-03-23T13:26:47Z', u'id': u'717aa547-878c-4591-b737-92a84c4bb064', u'resources': [u'arn:aws:ec2:us-east-1:367839381035:instance/i-0698e7d5720e30809']}

from aws-lambda-ddns-function.

jicowan avatar jicowan commented on June 29, 2024

I'm having trouble seeing where the problem is. The function extracts the instance ID from the event, instance_id=event[detail][instance-id] and then passes it to the describe_instances method. Can you add another print instance statement after line 37 and 42? Does the IAM policy you attached to the function have permission to query EC2?

from aws-lambda-ddns-function.

davidrobertson avatar davidrobertson commented on June 29, 2024

The role (ddns-lambda-role) has access to EC2, per the policy:
{"Version":"2012-10-17","Statement":[{"Action":"ec2:Describe*","Resource":"","Effect":"Allow"},{"Action":["dynamodb:"],"Resource":"","Effect":"Allow"},{"Action":["logs:CreateLogGroup","logs:CreateLogStream","logs:PutLogEvents"],"Resource":"","Effect":"Allow"},{"Action":["route53:"],"Resource":[""],"Effect":"Allow"}]}

That said, the Access Advisor says that the role has not tried to access either EC2, nor Route 53 at all

Amazon CloudWatch Logs ddns-lambda-role Today
Amazon DynamoDB ddns-lambda-role Today
Amazon EC2 ddns-lambda-role Not accessed in the tracking period
Amazon Route 53 ddns-lambda-role Not accessed in the tracking period

Remember - this is all done via the CloudFormation template.

from aws-lambda-ddns-function.

davidrobertson avatar davidrobertson commented on June 29, 2024

Also, there are no new log showing up after adding 'print instance' after lines 37 and 42.

from aws-lambda-ddns-function.

jicowan avatar jicowan commented on June 29, 2024

That policy doesn't look right. Can you try replacing it with the policy in the ddns-pol.json file or re-post it here surrounded by triple `. Thanks for your patience.

from aws-lambda-ddns-function.

davidrobertson avatar davidrobertson commented on June 29, 2024

No, thanks for your patience.

I've replaced the policy, and it's still not working.

Still nothing useful in the logs either:

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

from aws-lambda-ddns-function.

jicowan avatar jicowan commented on June 29, 2024

Awesome! I may need to increase the timeout in the CFN template.

from aws-lambda-ddns-function.

mustanggb avatar mustanggb commented on June 29, 2024

Just ran into this issue, any chance you can update the blog as well?
https://aws.amazon.com/blogs/compute/building-a-dynamic-dns-for-route-53-using-cloudwatch-events-and-lambda/

from aws-lambda-ddns-function.

jstrahn avatar jstrahn commented on June 29, 2024

I also encountered this same error. Thank you @davidrobertson for figuring this out. Saved me a lot of time.

from aws-lambda-ddns-function.

painty1 avatar painty1 commented on June 29, 2024

Hi. I'm getting this error also. I have tried increasing the timeout in the function but still get the same error. Does it make a difference that I'm using a windows instance for this?
Thanks

from aws-lambda-ddns-function.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.