aws-amplify / amplify-backend

Home to all tools related to Amplify's code-first DX (Gen 2) for building fullstack apps on AWS
Apache License 2.0
154 stars 52 forks source link

post-confirmation lambda doesn't get generated properly in sandbox (NextJS) #1755

Closed roguewindrunner closed 1 week ago

roguewindrunner commented 1 month ago

Environment information

System:
  OS: Windows 11 10.0.22621
  CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  Memory: 6.80 GB / 15.85 GB
Binaries:
  Node: 20.15.1 - C:\Program Files\nodejs\node.EXE
  Yarn: 1.22.22 - C:\Program Files\nodejs\yarn.CMD
  npm: 10.7.0 - C:\Program Files\nodejs\npm.CMD
  pnpm: 9.5.0 - C:\Program Files\nodejs\pnpm.CMD
NPM Packages:
  @aws-amplify/backend: 1.0.4
  @aws-amplify/backend-cli: 1.1.1
  aws-amplify: 6.4.0
  aws-cdk: 2.149.0
  aws-cdk-lib: 2.149.0
  typescript: 5.5.3
AWS environment variables:
  AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
  AWS_SDK_LOAD_CONFIG = 1
  AWS_STS_REGIONAL_ENDPOINTS = regional
No CDK environment variables

Description

I tried following the documentation for creating a user profile record with post-confirmation trigger with some modification to the data to conform to what I need. The sandbox showed no error during deployment, but when after signing up and confirming it showed the following error:

image

So I checked the lambda function associated with the trigger and found that these were generated inside the index.mjs file:

index.mjs: image

index.mjs.map: image

Those doesn't seem like something that should be inside an .mjs file.

Thank you in advance for the assistance

Misc

Folder Structure

amplify
├───auth
│       ├───post-confirmation
│       │        ├───graphql
│       │        │        ├───API.ts
│       │        │        ├───mutations.ts
│       │        │        ├───queries.ts
│       │        │        └───mutations.ts         
│       │        ├───handler.ts
│       │        └───resource.ts
│       └───resource.ts
├───data
│       └───resource.ts
│      
├───backend.ts
└───tsconfig.json
sobolk commented 1 month ago

@roguewindrunner The content of index.mjs looks like that because under the hood esbuild is used to minify the code and bundle dependencies. This is expected. The error you're observing is most likely due to some bug in post confirmation lambda code or wrong configuration of that lambda (permissions?). It might be worth to inspect that lambda's logs in AWS Console to see what actual error is. If this doesn't help please share zip with an app that reproduces your problem if possible.

roguewindrunner commented 3 weeks ago

I see. I ended up playing around with the Node runtime version and got it working. Thank you for the guidance and help.

ykethan commented 3 weeks ago

Hey @roguewindrunner, glad to hear you were able to mitigate the issue. Wanted to get some additional information on the issue. Did you observe any error messages in the CloudWatch function logs? New runtime the function was updated to?

ykethan commented 1 week ago

Closing the issue due to inactivity. Do reach out if you are still experiencing this issue.