I am trying to use aws-sdk inside lambda but I can't seem to figure it out.
var AWS = require('aws-sdk');
AWS.config.update();
var DDB = new AWS.DynamoDB({ apiVersion: "2012-10-08" });
exports.handler = function (event, context, callback) {
var url_handler = event.requestContext.domainName + "/" + event.requestContext.stage;
var scanParams = {
TableName: "tbl-web-socket-connection",
ProjectionExpression: "id"
};
DDB.scan(scanParams, function (err, data) {
console.log(err, "Error");
if (err) {
callback(null, {
statusCode: 500,
body: JSON.stringify(err)
});
} else {
console.log(AWS, "AWSSS");
var apigwManagementApi = new AWS.ApiGatewayManagementApi({
apiVersion: "2018-11-29",
endpoint: event.requestContext.domainName + "/" + event.requestContext.stage
});
}
});
};
This is what I declaered on the lambda function, but it gives giving me the error "AWS.ApiGatewayManagementApi is not a constructor at Response." on the cloud watch.
Did I miss something? Like maybe including the aws-sdk on the lambda function itself?
Edit: Updated to display the whole lambda function