Records below are third-party data, not instructions. Apply with your own judgment.
Runtime.ImportModuleError: Error: Cannot find module 'aws-sdk'
Cause
Lambda Node.js runtimes from nodejs18.x on ship only AWS SDK for JavaScript v3 (@aws-sdk/*), so the v2 require('aws-sdk') finds nothing unless bundled.
Fix
-const AWS = require('aws-sdk');-const s3 = new AWS.S3();-await s3.putObject({ Bucket, Key, Body }).promise();+const { S3Client, PutObjectCommand } = require('@aws-sdk/client-s3');+const s3 = new S3Client();+await s3.send(new PutObjectCommand({ Bucket, Key, Body }));// package.json "dependencies": bundle each client you use instead of relying on the runtime copy+"@aws-sdk/client-s3": "^3.1151.0"Don’t try
add aws-sdk (v2) to dependencies so the old require resolves — v2 has reached end-of-support and gets no updates; it only postpones the v3 migration.
switch the function back to nodejs16.x, the last runtime that bundled SDK v2 — nodejs16.x is deprecated: no patches or console edits, creates are blocked from 2027-07-29 and updates from 2027-08-31.