Skip to content

Bug: TableManager Lambda missing lodash.isequal dependency causes all DynamoDB table creation to failΒ #3021

@he-engineer

Description

@he-engineer

Bug Report: TableManager Lambda Missing lodash.isequal Dependency

Environment

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

  1. 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 });
  2. Deploy to sandbox or production:

    npx ampx sandbox
  3. Observe CloudFormation failure:

    • Auth stack: βœ… CREATE_COMPLETE
    • Data stack: ❌ CREATE_FAILED
    • Error: "CloudFormation did not receive a response from your Custom Resource"
  4. 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:

  1. lodash.isequal is deprecated (last published 9 years ago)
  2. Not included in Lambda bundle dependencies
  3. 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

  1. ❌ patch-package: Doesn't work (Lambda uses pre-bundled code)
  2. ❌ Lambda layers: Can't modify Amplify's internal Lambda
  3. ❌ Downgrade: Bug exists in all Gen 2 versions
  4. ⚠️ 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 lodash in Lambda bundle dependencies
  • Replacing lodash.isequal with custom implementation
  • Updating to a maintained lodash package

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions