I'm invoking the following lambda function to describe an instance information:
'use strict'
var aws = require('aws-sdk');
exports.handler = function(event, context) {
var instanceID = JSON.parse(event.Records[0].Sns.Message).Trigger.Dimensions[0].value;
aws.config.region = 'us-east-1';
var ec2 = new aws.EC2;
var params = {InstanceIds: [instanceID]};
ec2.describeInstances(params, function(e, data) {
if (e)
console.log(e, e.stack);
else
console.log(data);
}
};
In CloudWatch Logs I can see that function runs until the end, but doesn't log nothing inside ec2.describeInstances method:
END RequestId: xxxxxxxxxxxxxx REPORT RequestId: xxxxxxxxxxxxxx Duration: xx ms Billed Duration: xx ms Memory Size: xx MB Max Memory Used: xx MB
My lambda function has VPC access and IAM Role of AdministratorAccess (full access). For some reason, it can't run ec2.describeInstances method. What is wrong and how can I fix it?