1

I have a lambda function, which I'm trying to use to connect to a DynamoDB table I have. I'm using this code to establish the connection:

...

context.getLogger().log("Before create client..");

AmazonDynamoDB ddb = AmazonDynamoDBClientBuilder.standard()
    .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(
    "https://dynamodb.ap-southeast-2.amazonaws.com", "ap-southeast-2")).build();

context.getLogger().log("After create client..");

...

The output I have from the function is as follows:

==================== FUNCTION OUTPUT ====================
{"errorMessage":"2017-07-28T01:11:34.092Z aeee6505-7331-11e7-b28b-db98038611cc Task timed out after 5.00 seconds"}
==================== FUNCTION LOG OUTPUT ====================
START RequestId: aeee6505-7331-11e7-b28b-db98038611cc Version: $LATEST
Before create client..END RequestId: aeee6505-7331-11e7-b28b-db98038611cc
REPORT RequestId: aeee6505-7331-11e7-b28b-db98038611cc  Duration: 5003.51 ms    Billed Duration: 5000 ms    Memory Size: 256 MB Max Memory Used: 62 MB  
2017-07-28T01:11:34.092Z aeee6505-7331-11e7-b28b-db98038611cc Task timed out after 5.00 seconds

As you can see, it times out when trying to build the connection and never prints the second log statement. Is there a reason it would timeout rather than throwing an exception, e.g. if there's an error with the IAM role or something? The dynamoDB region and lambda region are the same (Sydney - ap-southeast-2), so I'd have thought this would work.

The IAM role the lambda function is using has the following permissions:

AmazonDynamoDBReadOnlyAccess

AmazonS3ReadOnlyAccess

AWSLambdaBasicExecutionRole

2 Answers 2

4

Fixed it.. bumped up the memory of the lambda function to 1024MB. Seriously not sure why that was required given memory used was always around 60-70MB :/

Sign up to request clarification or add additional context in comments.

3 Comments

Are you sure this is memory issue? log saying used memory is 62MB. My guess is your DynamoDB query took more time.
@kosa The strange thing is there was no query.. it was literally unable to establish a connection until I increased the memory, then it suddenly started working..
This was pretty strange, but yeah it solved my problem too. Probably AWS force you to use at least 1024 MB when using DynamoDB.
1

It's memory issue only..I changed lambda function to 1024MB it start working fine

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.