I am working through a lambda course which was done using v8.10. I am trying to use nodejs v10.x since that is what I want to use for my project in the future.
I am
Since node.js v10 aws lambda does not support importing libraries from lambda itself.
from the docs :
A deployment package is a ZIP archive that contains your function code and dependencies. You need to create a deployment package if you use the Lambda API to manage functions, or if you need to include libraries and dependencies other than the AWS SDK.
If your function depends on libraries other than the SDK for JavaScript, install them to a local directory with NPM, and include them in your deployment package. You can also include the SDK for JavaScript if you need a newer version than the one included on the runtime, or to ensure that the version doesn't change in the future.
More about AWS Lambda Deployment Package in Node.js
Update 02/05/2020:
node.js 8.10 is now deprecated, you should use node.js 10 or 12.
https://docs.aws.amazon.com/lambda/latest/dg/runtime-support-policy.html
As per accepted answer, it's now required that lambda won't have third party support directly. (because Node 8 version is deprecated now which might've still accepted).
const aws = require('aws-sdk');
const s3 = new aws.S3();
// const uuid = require('uuid'); comment this out
exports.handler = async (event, context) => {
console.log("Get the event to our S3POC class - " + JSON.stringify(event));
// const newUUID = context.awsRequestId();
const newUUID = context.awsRequestId;
console.log("The file name is:" + newUUID);
//put our sentence into the s3 bucket
return s3.putObject({
Bucket: "helloworld-s3.arkhadbot.com",
Key: "test" + ".json"
});
};
AWS Request IDs might look like so: requestId: 'daf9dc5e-1628-4437-9e2d-2998efaa73b4'