Problem: `Could not include required dependency '@...
# aws
b
Problem:
Could not include required dependency '@aws-sdk/client-cognito-identity-provider'
This causes
new CognitoIdentityProviderClient()
to be undefined (see screenshot from lambda) Situation: I am defining a lambda function with
new aws.lambda.CallbackFunction()
. Within that I am using a module from the
@aws-sdk/client-cognito-identity-provider
. I expect this function to build and include dependecies used that I defined in the
callback
. This does not happen. Instead I get a warning (see Problem). Question What do I have to do so that dependencies are included?
figured out that
sam build
(AWS SAM) is not enough. That's why I went with a custom esbuild build config, to build my lambdas properly. Simple example:
./scripts/build.js
Copy code
require('esbuild').build({
  entryPoints: ['./src/sign-up'],
  bundle: true,
  minify: true,
  platform: 'node',
  target: 'node16.16.0',
  outfile: './build/sign-up/index.js',
  format: 'cjs',

}).catch(() => process.exit(1))