cannot get aws lambda to send sms via aws sns - amazon-web-services

I have copied the example in the various guides on the internet, including the fairly recent topic on SO:
How to send SMS using Amazon SNS from a AWS lambda function
I've implemented successfully the code from https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/sns-examples-sending-sms.html on my local nodejs server, however when i do the same on Lambda nothing happens, not even console.log???
This is the code i am using in Lambda:
const AWS = require('aws-sdk');
exports.handler = async (event) => {
AWS.config.update({region: 'eu-west-2'});
var params = {
Message: 'TEXT_MESSAGE', /* required */
PhoneNumber: '+1346879',
};
// Create promise and SNS service object
var publishTextPromise = new AWS.SNS({apiVersion: '2010-03-31'}).publish(params).promise();
// Handle promise's fulfilled/rejected states
publishTextPromise.then(
function(data) {
console.log("MessageID is " + data.MessageId);
const response = {
statusCode: 200,
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(data)
};
console.log('Server response function');
return response;
}).catch(
function(error) {
//console.error(err, err.stack);
const response = {
statusCode: 500,
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({error: 'Internal server error', message: error})
};
return response;
});
}
Needless to say i tried various flavours of what seems to be an elementary piece of code...
Logs say exactly this:
2020-10-29T00:29:21.820+00:00 START RequestId: 8dbaedac-1f98-4319-9ac5-acba1d8860c5 Version: $LATEST
2020-10-29T00:29:22.242+00:00 Lambda Insights extension initializing.
2020-10-29T00:29:22.242+00:00 EXTENSION Name: cloudwatch_lambda_agent State: Ready Events: [INVOKE,SHUTDOWN]
2020-10-29T00:29:22.838+00:00 END RequestId: 8dbaedac-1f98-4319-9ac5-acba1d8860c5
2020-10-29T00:29:22.838+00:00
Copy
REPORT RequestId: 8dbaedac-1f98-4319-9ac5-acba1d8860c5 Duration: 594.62 ms Billed Duration: 600 ms Memory Size: 128 MB Max Memory Used: 99 MB Init Duration: 448.90 ms
REPORT RequestId: 8dbaedac-1f98-4319-9ac5-acba1d8860c5 Duration: 594.62 ms Billed Duration: 600 ms Memory Size: 128 MB Max Memory Used: 99 MB Init Duration: 448.90 ms
I have set permissions in the same exact way both on my user and on lambda:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "sns:*",
"Resource": "*"
}
]
}
Any thought?

I think that you have to return a promise to ensure all the tasks will be executed till the end.
If your code performs an asynchronous task, return a promise to make sure that it finishes running. When you resolve or reject the promise, Lambda sends the response or error to the invoker.
const AWS = require('aws-sdk');
exports.handler = async (event) => {
AWS.config.update({region: 'eu-west-2'});
var params = {
Message: 'TEXT_MESSAGE', /* required */
PhoneNumber: '+1346879',
};
// Create promise and SNS service object
var publishTextPromise = new AWS.SNS({apiVersion: '2010-03-31'}).publish(params).promise();
return new Promise((resolve, reject) => {
// Handle promise's fulfilled/rejected states
publishTextPromise.then((data) => {
console.log("MessageID is " + data.MessageId);
const response = {
statusCode: 200,
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(data)
};
console.log('Server response function');
resolve(response);
}).catch((error) => { reject(Error(error)); });
});
}

Check the lambda execution time, try to increase it to 15 mins.
This SNS is having two types of messages 1.Promotional 2.Transactional
By default it choose promotional. If end users is having DND enabled to his number. Then your message will not delivered.
If it is related to transactional use the below object for sending transactional messages.
{
Message: 'Message',
PhoneNumber: '+XXX',
MessageAttributes: {
'AWS.SNS.SMS.SMSType': {
DataType: 'String',
StringValue: 'Transactional'
}
}

Related

Not receiving SMS when sending it through SNS in lambda

I am sending the OTP using AWS SNS service when in a lambda function my code is this
const otp = generateOTP();
const message = `Your XXXX Verification Code is ${otp} .`;
var params = {
Message: message,
PhoneNumber: "+91xxxxxxxxxx",
};
AWS.config.update({region: 'ap-south-1'});
var publishTextPromise = new AWS.SNS({apiVersion: '2022-04-01'}).publish(params).promise();
return new Promise((resolve, reject) => {
publishTextPromise.then((data) => {
console.log("MessageID is " + data.MessageId);
const response = {
statusCode: 200,
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(data)
};
console.log('Server response function');
resolve(response);
}).catch((error) => { reject(Error(error)); });
});
and i am getting this response when invoking this lambda function
Server response function
{
"statusCode": 200,
"headers": {
"Content-Type": "application/json"
},
"body": {
"ResponseMetadata": {
"RequestId": "29796d67-f32e-5e42-a761-37a72809164d"
},
"MessageId": "2f8ffee0-7e0d-5cd3-a5b0-a420a52a14dc"
}
}
But I am not receiving the SMS on that number I don't know what is the problem here cause the I am getting resolved response in the console which means the SMS is send but I am not received it.
Do I have to config the sns manual in aws sns mobile -> text messaging or something??
or is their any other way to send verification otp ?

Sending an email from an AWS Lambda function

I've created a basic lambda function that should send an email from the SES service, but it is not working.
I've followed this tutorial: here. I've created the proper IAM policy and attached it to the function, but I don't think that's the problem.
I've created a test config for the function with and the control flow is not reaching inside of sendEmail, and I'm not sure why.
const aws = require('aws-sdk')
const ses = new aws.SES({ region: 'us-east-1' });
exports.handler = async (event, context, callback) => {
const printOut = JSON.stringify(event);
console.log(`Received event: ${printOut}`);
const params = {
Destination: {
ToAddresses: ["xxxxx.xxxx#gmail.com"]
},
Message: {
Body: {
Text: {
Data: event['desc']
}
},
Subject: {
Data: "Email from xxxxxxx Contact Us Form"
}
},
Source: "xxxxxxxxxxxxxxxxx#gmail.com"
};
console.log(`sending: ${JSON.stringify(params)}`);
ses.sendEmail(params, function (err, data) {
callback(null, { err: err, data: data });
if (err) {
console.error(err);
context.fail(err);
} else {
console.log(data);
context.succeed(event);
}
console.log(`Done!`);
});
};
Here is my current output:
Response:
null
Request ID:
"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxx"
Function Logs:
START RequestId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxx Version: $LATEST
2019-11-12T01:28:48.352Z xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxx INFO Received event: {"name":"Redacted","email":"xxxxx.xxxx#gmail.com","desc":"Test message"}
2019-11-12T01:28:48.372Z xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxx INFO sending: {"Destination":{"ToAddresses":["xxxxx.xxxx#gmail.com"]},"Message":{"Body":{"Text":{"Data":"Test message"}},"Subject":{"Data":"Email from xxxxxx Contact Us Form"}},"Source":"xxxxxxxxxxxxxxx#gmail.com"}
END RequestId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxx
REPORT RequestId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxx Duration: 590.10 ms Billed Duration: 600 ms Memory Size: 128 MB Max Memory Used: 94 MB Init Duration: 359.55 ms
As you can see, the console outs/errors inside the sendEmail function are never being called. Not really sure why.
I did make sure to verify both of the email addresses I'm testing with, but no dice.
You have to either make it non-async or return a promise back to the caller (you can return that promise directly to the runtime). Like this:
const aws = require('aws-sdk')
const ses = new aws.SES({region: 'us-east-1'});
exports.handler = async (event, context, callback) => {
const printOut = JSON.stringify(event);
console.log(`Received event: ${printOut}`);
const params = {
Destination: {
ToAddresses: ["xxxxx.xxxx#gmail.com"]
},
Message: {
Body: {
Text: {
Data: event['desc']
}
},
Subject: {
Data: "Email from xxxxxxx Contact Us Form"
}
},
Source: "xxxxxxxxxxxxxxxxx#gmail.com"
};
console.log(`sending: ${JSON.stringify(params)}`);
return ses.sendEmail(params, null).promise();
};

Why isn't Dynamodb.put working in Lambda Function? Returns null. How to debug?

Debugging lambda is frustrating.
I've got a very simple lambda function:
const AWS = require('aws-sdk')
const dynamodb = new AWS.DynamoDB.DocumentClient({region: 'ap-southeast-2'});
exports.handler = async (event, context, callback) => {
const params = {
TableName: 'people-dev',
Item: {
id: '1',
name: 'person',
email: 'person#example.com'
}
};
dynamodb.put(params, (err, data) => {
if(err) {
callback(err, null)
} else{
callback(null, data)
}
});
};
The test response is:
Response:
null
Request ID:
"3d7e9329-3843-4760-917d-4b4d4781dbd7"
Function Logs:
START RequestId: 3d7e9329-3843-4760-917d-4b4d4781dbd7 Version: $LATEST
END RequestId: 3d7e9329-3843-4760-917d-4b4d4781dbd7
REPORT RequestId: 3d7e9329-3843-4760-917d-4b4d4781dbd7 Duration: 243.13 ms Billed Duration: 300 ms Memory Size: 128 MB Max Memory Used: 29 MB
Nothing is being written to Dynamo.
Nothing useful is logged in cloudwatch.
Yes, the function has full permissions to DynamoDB.
Put async back to its place as using callbacks is outdated and much more error prone. Use the built-in promise() methods available on the node.js aws-sdk and just await on these promises. If you want to deal with errors, just surround your code with a try/catch block.
const AWS = require('aws-sdk')
const dynamodb = new AWS.DynamoDB.DocumentClient({region: 'ap-southeast-2'});
exports.handler = async (event) => {
const params = {
TableName: 'people-dev',
Item: {
id: '1',
name: 'person',
email: 'person#example.com'
}
};
await dynamodb.put(params).promise()
return {
statusCode: 200,
body: JSON.stringify({message: 'Success'})
}
};
More on async/await
The issue was that the handler was executing asynchronously.
exports.handler = async (event, context, ....
Changing it to the following, fixed the problem:
exports.handler = function (event, context, ....

Serverless Lambda invoking Lambda. Getting no errors but a empty response

Now day we can use the AWS StepFunctions if we want to make an lambda function to call another one.
But for now I need do support the code in production that was written before the StepFunctions time.
For that reason I need to understand how it works. I was trying to create a very simple lambda calling another lambda function trough AWS-SDk.
I have the follow serverless.yml
service: lambdaCallLambda
provider:
name: aws
runtime: nodejs6.10
functions:
hello:
handler: handler.hello
funcOne:
handler: handler.funcOne
funcTwo:
handler: handler.funcTwo
#Must install aws-sdk. #npm install --save aws-sdk
And this is the handler.js:
'use strict';
//https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html
var Lambda = require('aws-sdk/clients/lambda');
module.exports.hello = (event, context, callback) => {
const response = {
statusCode: 200,
body: JSON.stringify({
message: 'hello',
input: event,
}),
};
callback(null, response);
};
module.exports.funcOne = (event, context, callback) => {
var text='';
var i = 0;
for (i = 0; i < 5; i++) {
text += "The number is " + i + "\n";
}
console.log(text);
//https://docs.aws.amazon.com/general/latest/gr/rande.html
const lambda = new Lambda({
region: 'us-east-1'
});
console.log('control 3');
/*
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html#constructor-property
To invoke a Lambda function
This operation invokes a Lambda function
https://docs.aws.amazon.com/lambda/latest/dg/API_Invoke.html
Payload - JSON that you want to provide to your Lambda function as input.
*/
var params = {
ClientContext: "lambdaCallLambda",
FunctionName: "lambdaCallLambda-dev-funcOne",
InvocationType: "Event",
LogType: "Tail",
Payload: '{"jsonKey2":123}',
Qualifier: "1"
};
lambda.invoke(params, function(err, data) {
if (err){
console.log('control error\n');
console.log(err, err.stack); // an error occurred
}
else{
console.log('control OK\n');
console.log(data); // successful response
}
/*
data = {
FunctionError: "",
LogResult: "",
Payload: <Binary String>,
StatusCode: 123
}
*/
});
};
module.exports.funcTwo = async (event, context) => {
return 2;
//return '{"funcTwo":20000}';
//console.log("funcTwo = " + event);
};
After deploy sls deploy and call funcOne I get this 2 outputs:
LOCAL:
sls invoke local --function funcOne
Serverless: INVOKING INVOKE
The number is 0
The number is 1
The number is 2
The number is 3
The number is 4
control 3
control OK
{ StatusCode: 202, Payload: '' }
Invoking remotely in AWS:
sls invoke --function funcOne
{
"errorMessage": "Unexpected token (",
"errorType": "SyntaxError",
"stackTrace": [
" ^",
"SyntaxError: Unexpected token (",
"createScript (vm.js:56:10)",
"Object.runInThisContext (vm.js:97:10)",
"Module._compile (module.js:542:28)",
"Object.Module._extensions..js (module.js:579:10)",
"Module.load (module.js:487:32)",
"tryModuleLoad (module.js:446:12)",
"Function.Module._load (module.js:438:3)",
"Module.require (module.js:497:17)",
"require (internal/module.js:20:19)"
]
}
Error --------------------------------------------------
Invoked function failed
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information -----------------------------
OS: linux
Node Version: 8.11.3
Serverless Version: 1.29.2
Does someone knows hat is happening here? Specially for the first scenario where I dont have any error.
This is what I get from the documentation
Parameters:
err (Error) — the error object returned from the request. Set to null if the request is successful.
data (Object) — the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:
Status — (Integer)
It will be 202 upon success.
Update
After Eduardo Díaz suggestion -
I have changed lambda.invoke to:
lambda.invoke({
FunctionName: 'lambdaCallLambda-dev-funcOne',
Payload: JSON.stringify(event, null, 2)
}, function(error, data) {
if (error) {
console.log('control ErrorFoncOne\n');
context.done('error', error);
}
if(data.Payload){
console.log('control SuccessFoncOne\n');
context.succeed(data)
}
});
And this what I get for Local and Remote:
{
"errorMessage": "Unexpected token (",
"errorType": "SyntaxError",
"stackTrace": [
"Module.load (module.js:487:32)",
"tryModuleLoad (module.js:446:12)",
"Function.Module._load (module.js:438:3)",
"Module.require (module.js:497:17)",
"require (internal/module.js:20:19)"
]
}
It is a SyntaxError. There is a "(" somewhere.
I have found another developer with the same error here.
Note:
No error logs in CloudWatch
Try to send the event in the payload:
lambda.invoke({
FunctionName: 'name_lambda_function',
Payload: JSON.stringify(event, null, 2)
}, function(error, data) {
if (error) {
context.done('error', error);
}
if(data.Payload){
context.succeed(data.Payload)
}
});
I strongly suspect this problem is rooted in your handler signature for funcTwo:
module.exports.funcTwo = async (event, context) => {
NodeJS 6.10 does not support async/await. Node always complains about the token after the async token, for whatever reason. If you don't use a fat arrow function:
module.exports.funcTwo = async function(event, context) {
Node will complain: Unexpected token function.
Options
Deploy the function to NodeJS 8.10 instead.
Get rid of the async keyword in the handler signature.
Use a build tool (like serverless-webpack) to transpile the function down to ES6 (or lower).
Note: If you stick with the 6.10 runtime, I think you'll want to do something like context.succeed(2); or callback(null, 2);, rather than return 2;. Simply using a return statement does seem to work on 8.10.
I have found the issue. We need JSON.stringfy in the playload in lamdda.invoke method. No extra parameters are needed. Only the JSON as per the documentation.
lambda.invoke({
FunctionName: 'lambdaCallLambda-dev-funcTwo',
Payload: JSON.stringify({"jsonKey2":i})
...
From the AWS documentation for playload we have:
Payload
JSON that you want to provide to your Lambda function as input.
Note:
the async in front of the functions
lambda.invoke({
FunctionName: 'lambdaCallLambda-dev-funcTwo',
Payload: JSON.stringify({"jsonKey2":i})
}, async function(error, data) { ...
and
module.exports.funcTwo = async(event, context, callback) => { ...
Gives me this output:
Loop nb=1
Loop nb=2
Loop nb=3
Loop nb=4
Loop nb=5
{"message":"hello from funcTwo","event":{"jsonKey2":3}}
{"message":"hello from funcTwo","event":{"jsonKey2":2}}
{"message":"hello from funcTwo","event":{"jsonKey2":1}}
{"message":"hello from funcTwo","event":{"jsonKey2":5}}
{"message":"hello from funcTwo","event":{"jsonKey2":4}}
While the absence of async gives me:
Loop nb=1
Loop nb=2
Loop nb=3
Loop nb=4
Loop nb=5
{"message":"hello from funcTwo","event":{"jsonKey2":1}}
{"message":"hello from funcTwo","event":{"jsonKey2":2}}
{"message":"hello from funcTwo","event":{"jsonKey2":3}}
{"message":"hello from funcTwo","event":{"jsonKey2":4}}
{"message":"hello from funcTwo","event":{"jsonKey2":5}}
I'm going to share the handle.js code just in case someone else needs it:
'use strict';
//https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html
var Lambda = require('aws-sdk/clients/lambda');
module.exports.hello = (event, context, callback) => {
const response = {
statusCode: 200,
body: JSON.stringify({
message: 'hello',
input: event,
}),
};
callback(null, response);
};
/*
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html#constructor-property
To invoke a Lambda function
This operation invokes a Lambda function
https://docs.aws.amazon.com/lambda/latest/dg/API_Invoke.html
Payload - JSON that you want to provide to your Lambda function as input.
Serverless Framework: Lambdas Invoking Lambdas
https://lorenstewart.me/2017/10/02/serverless-framework-lambdas-invoking-lambdas/
How to escape async/await hell
https://medium.freecodecamp.org/avoiding-the-async-await-hell-c77a0fb71c4c
Iterating a Loop Using Lambda
https://docs.aws.amazon.com/step-functions/latest/dg/tutorial-create-iterate-pattern-section.html
AWS Lambda “Process exited before completing request”
https://stackoverflow.com/questions/31627950/aws-lambda-process-exited-before-completing-request
Class: AWS.Lambda
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html#constructor-property
Invoke
https://docs.aws.amazon.com/lambda/latest/dg/API_Invoke.html#API_Invoke_RequestSyntax
Programming Model(Node.js)
https://docs.aws.amazon.com/lambda/latest/dg/programming-model.html
AWS Lambda Examples
https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/lambda-examples.html
*/
//The event is a file inserted in S3. This function funcOne reads the file and loop trough all quantities of products.
//Invoking a lamda function funcTwo for each process in the loop.
module.exports.funcOne = (event, context, callback) => {
//https://docs.aws.amazon.com/general/latest/gr/rande.html
const lambda = new Lambda({
region: 'us-east-1'
});
//Loop
//nbProducts = loop trough the products JSON list in S3
var nbProducts=5;
for (let i = 1; i <= nbProducts; i++) {
console.log('Loop nb='+i+'\n');
lambda.invoke({
FunctionName: 'lambdaCallLambda-dev-funcTwo',
Payload: JSON.stringify({"jsonKey2":i})
}, async function(error, data) {
if (error) {
//console.log('control ErrorFoncOne\n');
context.done('error', error);
}
if(data.Payload){
//console.log('control SuccessFoncOne\n');
console.log(data.Payload);
//context.succeed(data)
}
});
}
};
module.exports.funcTwo = async(event, context, callback) => {
callback(null, { message: 'hello from funcTwo', event });
};
just a change of one line would get you the respose
do change in params
'use strict';
//https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html
var Lambda = require('aws-sdk/clients/lambda');
module.exports.hello = (event, context, callback) => {
const response = {
statusCode: 200,
body: JSON.stringify({
message: 'hello',
input: event,
}),
};
callback(null, response);
};
module.exports.funcOne = (event, context, callback) => {
var text='';
var i = 0;
for (i = 0; i < 5; i++) {
text += "The number is " + i + "\n";
}
console.log(text);
//https://docs.aws.amazon.com/general/latest/gr/rande.html
const lambda = new Lambda({
region: 'us-east-1'
});
console.log('control 3');
var params = {
ClientContext: "lambdaCallLambda",
FunctionName: "lambdaCallLambda-dev-funcOne",
InvocationType: "RequestResponse", /* changed this line from
"Event" to "RequestResponse"*/
LogType: "Tail",
Payload: '{"jsonKey2":123}',
Qualifier: "1"
};
lambda.invoke(params, function(err, data) {
if (err){
console.log('control error\n');
console.log(err, err.stack); // an error occurred
}
else{
console.log('control OK\n');
console.log(data); // successful response
}
/*
data = {
FunctionError: "",
LogResult: "",
Payload: <Binary String>,
StatusCode: 123
}
*/
});
};
module.exports.funcTwo = async (event, context) => {
return 2;
//return '{"funcTwo":20000}';
//console.log("funcTwo = " + event);
};

Amazon ElasticTranscoder, How to wait for job completion?

I have a node.js lambda , triggered on S3 event. An Elastic Transcoder job is initiated like so:
let AWS = require('aws-sdk');
let s3 = new AWS.S3({apiVersion: '2012–09–25'});
let eltr = new AWS.ElasticTranscoder({apiVersion: '2012–09–25', region: 'us-west-2'});
exports.handler = (event, context, callback) => {
let pipelineId = 'keystone';
let bucket = event.Records[0].s3.bucket.name;
let key = event.Records[0].s3.object.key;
let etParams = {
PipelineId: pipelineId,
Input: {
Key: key,
FrameRate: 'auto',
Resolution: 'auto',
AspectRatio: 'auto',
Interlaced: 'auto',
Container: 'auto'
},
Outputs: [{
Key: key,
PresetId: '1351620000001-000010'
}]
};
eltr.createJob(etParams, function(err, data) {
if (err) {
console.log("ET error", err, err.stack);
} else {
console.log("Calling waitFor for Job Id:", data.Job.Id);
eltr.waitFor("jobComplete", {Id: data.Job.Id}, function(err, data) {
if (err) {
console.log("ET waitFor Error", err, err.stack);
} else {
console.log("ET Job finished", data, data.Job.Output.Key);
}
});
}
});
};
The transcoding process times out:
START RequestId: 82c0a1ce-5cf3-11e7-81aa-a3362402de83 Version: $LATEST
2017-06-29T17:51:03.509Z 82c0a1ce-5cf3-11e7-81aa-a3362402de83 Creating Job { PipelineId: 'keystone',
Input:
{ Key: 'f04d62af47.mp4',
FrameRate: 'auto',
Resolution: 'auto',
AspectRatio: 'auto',
Interlaced: 'auto',
Container: 'auto' },
Outputs:
[ { Key: 'f04d62af47.mp4',
PresetId: '1351620000001-000010' } ] }
2017-06-29T17:51:04.829Z 82c0a1ce-5cf3-11e7-81aa-a3362402de83 Calling waitFor for Job Id: 1498758664450-jxhdlx
END RequestId: 82c0a1ce-5cf3-11e7-81aa-a3362402de83
REPORT RequestId: 82c0a1ce-5cf3-11e7-81aa-a3362402de83 Duration: 3001.65 ms Billed Duration: 3000 ms Memory Size: 128 MB Max Memory Used: 37 MB
2017-06-29T17:51:06.260Z 82c0a1ce-5cf3-11e7-81aa-a3362402de83 Task timed out after 3.00 seconds
The above log output is repeated 3 times (lambda's three tries?)
I'm sure I'm missing something, can anybody please point the mistake?
All calls made to AWS Lambda must complete execution within 300 seconds. The default timeout is 3 seconds, but you can set the timeout to any value between 1 and 300 seconds.
And on your two retries conjecture, you are correct. If AWS Lambda is unable to fully process an asynchronous event then it will automatically retry the invocation twice, with delays between retries.