I am trying this in the AWS lambda console. I have installed npm install @aws-sdk/client-kinesis on my terminal and used zipped the file and created a lambda layer which has client-kinesis.
If use the following it works!
// ES5 example
const { KinesisClient, AddTagsToStreamCommand } = require("@aws-sdk/client-kinesis");
exports.handler = async (event) => {
// TODO implement
const response = {
statusCode: 200,
body: JSON.stringify('Hello from Lambda!'),
};
return response;
};
If I am using the following it is giving me errors-
//ES6+ example
import { KinesisClient, AddTagsToStreamCommand } from "@aws-sdk/client-kinesis";
exports.handler = async (event) => {
// TODO implement
const response = {
statusCode: 200,
body: JSON.stringify('Hello from Lambda!'),
};
return response;
};
"Runtime.UserCodeSyntaxError: SyntaxError: Cannot use import statement outside a module",
Question -
- How to make this work from the AWS lambda console ?
- Is there any harm in using as the ES5 vs ES6 ? is it only syntax or there are performance issues also?
Thanks !