-
Notifications
You must be signed in to change notification settings - Fork 102
Description
Bug Report: TableManager Lambda Missing lodash.isequal Dependency
Environment
- Package:
@aws-amplify/[email protected] - Affected Package:
@aws-amplify/[email protected] - Node Version: v20.x (Lambda runtime)
- Region: us-east-1
- Amplify Gen: Gen 2
Description
The TableManager Lambda function deployed by @aws-amplify/data-construct fails with Runtime.ImportModuleError because the deprecated lodash.isequal package is required but not bundled with the Lambda.
This causes all DynamoDB table creation to fail in Amplify Gen 2 Data constructs.
Error
Runtime.ImportModuleError: Error: Cannot find module 'lodash.isequal'
Require stack:
- /var/task/import-table.js
- /var/task/amplify-table-manager-handler.js
- /var/runtime/index.mjs
Reproduction Steps
-
Create any Amplify Gen 2 project with data models:
// amplify/data/resource.ts import { a, defineData } from '@aws-amplify/backend'; const schema = a.schema({ Todo: a.model({ content: a.string(), }).authorization(allow => [allow.owner()]), }); export const data = defineData({ schema });
-
Deploy to sandbox or production:
npx ampx sandbox
-
Observe CloudFormation failure:
- Auth stack: β CREATE_COMPLETE
- Data stack: β CREATE_FAILED
- Error: "CloudFormation did not receive a response from your Custom Resource"
-
Check TableManager Lambda logs:
aws logs tail /aws/lambda/<TableManagerFunction> --since 1h
Result:
INIT_START Runtime Version: nodejs:20.v82 ERROR Uncaught Exception {"errorType":"Runtime.ImportModuleError", "errorMessage":"Error: Cannot find module 'lodash.isequal'..."}
Root Cause
File: node_modules/@aws-amplify/data-construct/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/amplify-dynamodb-table/amplify-table-manager-lambda/import-table.js
Line 7:
const lodash_isequal_1 = __importDefault(require("lodash.isequal"));Problems:
lodash.isequalis deprecated (last published 9 years ago)- Not included in Lambda bundle dependencies
- Lambda bundling process excludes it
Impact
Severity: Critical π΄
- β All DynamoDB tables fail to create
- β Blocks all Amplify Gen 2 Data deployments
- β Affects sandbox, staging, and production
- β No workaround available (patch-package doesn't work for Lambda bundles)
Tested Versions
| Version | Status |
|---|---|
@aws-amplify/[email protected] |
β Fails |
@aws-amplify/[email protected] |
β Fails (different bug) |
Proposed Solutions
Option A: Use full lodash package (recommended)
Replace:
const lodash_isequal_1 = __importDefault(require("lodash.isequal"));With:
const { isEqual } = require("lodash");Update package.json to include lodash@^4.17.21
Option B: Implement custom isEqual
Replace deprecated package with custom deep equality function (no dependencies):
const isDeepEqual = (a, b) => {
if (a === b) return true;
if (a === null || b === null || a === undefined || b === undefined) return a === b;
if (Array.isArray(a) && Array.isArray(b)) {
if (a.length !== b.length) return false;
for (let i = 0; i < a.length; i++) {
if (!isDeepEqual(a[i], b[i])) return false;
}
return true;
}
if (typeof a === 'object' && typeof b === 'object') {
const keysA = Object.keys(a);
const keysB = Object.keys(b);
if (keysA.length !== keysB.length) return false;
for (const key of keysA) {
if (!Object.prototype.hasOwnProperty.call(b, key)) return false;
if (!isDeepEqual(a[key], b[key])) return false;
}
return true;
}
return false;
};Workarounds Attempted
- β patch-package: Doesn't work (Lambda uses pre-bundled code)
- β Lambda layers: Can't modify Amplify's internal Lambda
- β Downgrade: Bug exists in all Gen 2 versions
β οΈ Amplify Gen 1: Works, but requires full migration (2-3 days)
Additional Context
- Issue discovered during production deployment
- Confirmed in fresh Amplify Gen 2 projects
- No official documentation mentions this limitation
- Community reports similar lodash dependency issues in Gen 2
Related Issues
(Search for similar issues and link here)
Logs
Full Lambda Error Log
INIT_START Runtime Version: nodejs:20.v82 Runtime Version ARN: arn:aws:lambda:us-east-1::runtime:dd206d5c0479b082438417cc6b87731a870d3c7d4c6f2375bbacade0b935398d
2025-10-11T05:20:32.821Z undefined ERROR Uncaught Exception {"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module 'lodash.isequal'\nRequire stack:\n- /var/task/import-table.js\n- /var/task/amplify-table-manager-handler.js\n- /var/runtime/index.mjs","stack":["Runtime.ImportModuleError: Error: Cannot find module 'lodash.isequal'","Require stack:","- /var/task/import-table.js","- /var/task/amplify-table-manager-handler.js","- /var/runtime/index.mjs"," at _loadUserApp (file:///var/runtime/index.mjs:1192:17)"," at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1235:21)"," at async start (file:///var/runtime/index.mjs:1454:23)"," at async file:///var/runtime/index.mjs:1464:1"]}
INIT_REPORT Init Duration: 458.61 ms Phase: init Status: error Error Type: Runtime.ImportModuleError
CloudFormation Error
CREATE_FAILED | ZenShiftTable | CloudFormation did not receive a response from your Custom Resource. Please check your logs for requestId [6a8ecc5b-b4f2-471a-b359-5a9502bd6126].
Expected Behavior: TableManager Lambda should successfully create DynamoDB tables.
Actual Behavior: Lambda fails to initialize due to missing lodash.isequal dependency.
Request: Please fix this in the next patch release by either:
- Including
lodashin Lambda bundle dependencies - Replacing
lodash.isequalwith custom implementation - Updating to a maintained lodash package