Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lambda function fails to bundle node_modules in DynamoDB table management during deploy #3128

Open
micaelgomes opened this issue Jan 16, 2025 · 2 comments
Labels
Gen 2 pending-community-response Issue is pending a response from the author or community. pending-triage question Further information is requested transferred

Comments

@micaelgomes
Copy link

micaelgomes commented Jan 16, 2025

Environment information

System:
  OS: macOS 13.5.1
  CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700H
  Memory: 31.48 MB / 32.00 GB
  Shell: /bin/zsh
Binaries:
  Node: 22.12.0 - ~/.nvm/versions/node/v22.12.0/bin/node
  Yarn: 1.22.22 - ~/.yarn/bin/yarn
  npm: 10.9.0 - ~/.nvm/versions/node/v22.12.0/bin/npm
  pnpm: 9.15.4 - ~/Library/pnpm/pnpm
NPM Packages:
  @aws-amplify/auth-construct: 1.5.1
  @aws-amplify/backend: 1.13.0
  @aws-amplify/backend-auth: 1.4.2
  @aws-amplify/backend-cli: 1.4.7
  @aws-amplify/backend-data: 1.4.0
  aws-amplify: 6.12.1
  aws-cdk: 2.176.0
  aws-cdk-lib: 2.176.0

Describe the bug

During deployment (both sandbox and app), the internal Lambda function responsible for DynamoDB table management is being deployed without its node_modules, causing module import failures. The deployment gets stuck during table creation and fails with the following error:

<*> undefined ERROR Uncaught Exception {"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module 'lodash.isequal'\nRequire stack:\n- <*> <*> <*>,"stack":["Runtime.ImportModuleError: Error: Cannot find module 'lodash.isequal'"...

The deployment process hangs at:

2025-01-16T01:32:43.380Z [INFO]: 98/12 Currently in progress: amplify-d2t830pi2dqir1-main-branch-9c399377b4, data7552DF31, amplifyDataAccountNestedStackAccountNestedStackResourceC2EA4038, AccountTable

I've attempted various solutions including:

  • Updating esbuild to recommended versions (0.21.5, 0.23.1)
  • Clean installs and redeployments
  • Manual deletion of stacks after failed deployments

None of these attempts resolved the issue, and manual cleanup of stacks was required after each failed deployment.

Reproduction steps

  1. Create a new Amplify Gen2 project
  2. Define a data model using defineData:
const schema = a.schema({
  Account: a.model({
    id: a.string().required(),
    // ... other fields
  })
});

export const data = defineData({
  schema,
  authorizationModes: {
    defaultAuthorizationMode: "userPool"
  }
});
  1. Run npx ampx sandbox
  2. Observe deployment getting stuck at table creation step
  3. Check CloudWatch logs to see the Lambda failing with module import error
  4. Manual cleanup of stacks required due to failed deployment
@ykethan
Copy link
Member

ykethan commented Jan 17, 2025

Hey,👋 thanks for raising this! I'm going to transfer this over to our data repository for better assistance 🙂

@ykethan ykethan transferred this issue from aws-amplify/amplify-backend Jan 17, 2025
@stocaaro stocaaro transferred this issue from aws-amplify/amplify-data Jan 27, 2025
@AnilMaktala AnilMaktala added question Further information is requested Gen 2 labels Jan 27, 2025
@AnilMaktala
Copy link
Member

Hey @micaelgomes, Thank you for raising this issue. I’ve tried reproducing it using the schema below but wasn’t able to replicate the problem. To better understand the situation, could you confirm if the Account table includes any indexes, relationships, or identifiers? If possible, would you be able to share your Account model for further analysis?

const schema = a.schema({
  Todo: a
    .model({
      content: a.string().required(),
    })
    .authorization((allow) => [allow.guest()]),
});

export type Schema = ClientSchema<typeof schema>;

export const data = defineData({
  schema,
  authorizationModes: {
    defaultAuthorizationMode: "userPool",
  },
});
Image

@AnilMaktala AnilMaktala added the pending-community-response Issue is pending a response from the author or community. label Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gen 2 pending-community-response Issue is pending a response from the author or community. pending-triage question Further information is requested transferred
Projects
None yet
Development

No branches or pull requests

3 participants