I need some help with Lambda and CloudFormation

0

I write a template, but have something wroing with it, error like thiserror and how to create index.handler

  • 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

profile picture
Dgk
asked 9 months ago184 views
1 Answer
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;
          };
AWS
vtjean
answered 9 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions