Search code examples
node.jsamazon-web-servicesaws-lambdaamazon-ses

How to use aws-sdk in an AWS lambda


How do I use aws-sdk in a lambda. I'm trying to follow this https://aws.amazon.com/premiumsupport/knowledge-center/lambda-send-email-ses/ but I cannot get var aws = require("aws-sdk"); to work, I get an error "require is not defined in ES module scope, you can use import instead" How come AWS’s own solution doesn't even work?

EDIT: using import { AWS } from 'aws-sdk'; doesn't work either, I get the error "Cannot find package 'aws-sdk' imported from /var/task/index.mjs"


Solution

  • I solved the issue. I used import { SESClient, SendEmailCommand } from "@aws-sdk/client-ses"; instead