Comments (15)
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.
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.
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.
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.
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.
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.
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.
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.
Also, there are no new log showing up after adding 'print instance' after lines 37 and 42.
from aws-lambda-ddns-function.
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.
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.
Awesome! I may need to increase the timeout in the CFN template.
from aws-lambda-ddns-function.
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.
I also encountered this same error. Thank you @davidrobertson for figuring this out. Saved me a lot of time.
from aws-lambda-ddns-function.
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)
- Have to increase the Lambda function timeout to avoid KeyError: 'Item at line 61 HOT 1
- Getting KeyError when Lambda Functions executes HOT 1
- Reverse record support HOT 1
- Wrong CNAME/A records created with private domain name HOT 5
- Public and Private Route 53 with same name. HOT 2
- DynamoDB records are not removed HOT 3
- reverse record in new zone for each EC2 HOT 1
- Don't create reverse lookup zone for CNAME instances HOT 3
- 60s Sleep HOT 1
- Why need sleep 60 seconds if instance state is running? HOT 1
- Auto IP change in route53 DNS private zone for A records HOT 1
- Add to awesome-functions HOT 1
- Python Code error HOT 1
- python3 support HOT 1
- 60 second wait HOT 2
- IPv6 support HOT 1
- Python3 lambda function fails
- Support Python 3.9 HOT 6
- Json.loads error in get_item_from_dynamodb_table function
- Guarantees of using EventBridge and alternatives
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-lambda-ddns-function.