1 Answer
- Newest
- Most votes
- Most comments
0
You must do it as the following:
Code:
ZipFile: |
const { S3Client, ListBucketsCommand } = require("@aws-sdk/client-s3");
const s3 = new S3Client({ region: "us-east-1" }); // replace "us-east-1" with your AWS region
exports.handler = async function(event) {
const command = new ListBucketsCommand({});
const response = await s3.send(command);
return response.Buckets;
};
answered 9 months ago
Relevant content
- asked 9 months ago
- Accepted Answerasked 2 years ago
- AWS OFFICIALUpdated 3 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 9 months ago
Try and remove all the hyphens and quotes. Code: ZipFile: | const AWS = require('aws-sdk');..........
Or perhaps the issue is the ES module handler, see https://docs.aws.amazon.com/lambda/latest/dg/nodejs-handler.html
Review the zip file that was created and uploaded to Lambda (You can download it from the lambda function in the AWS Console). If it is not a valid javascript file, that will give you a clue on what needs to be changed in your template.
In the future, please include the code instead of a screenshot