Skip to content

(amplify-alpha): custom-resource-handler not found #28089

@tmokmss

Description

@tmokmss

Describe the bug

I get the below error on cdk synth using amplifyApp.addBranch(...). See the reproduction code below.

Error: Cannot find entry file at /root/cdk/node_modules/@aws-cdk/custom-resource-handlers/dist/aws-amplify-alpha/asset-deployment-handler/index.js
    at findEntry (/root/cdk/node_modules/aws-cdk-lib/aws-lambda-nodejs/lib/function.js:1:3405)
    at new NodejsFunction (/root/cdk/node_modules/aws-cdk-lib/aws-lambda-nodejs/lib/function.js:1:1391)
    at new AmplifyAssetDeploymentProvider (/root/cdk/node_modules/@aws-cdk/aws-amplify-alpha/lib/branch.ts:232:21)
    at Function.getOrCreate (/root/cdk/node_modules/@aws-cdk/aws-amplify-alpha/lib/branch.ts:223:82)
    at new Branch (/root/cdk/node_modules/@aws-cdk/aws-amplify-alpha/lib/branch.ts:190:54)
    at App.addBranch (/root/cdk/node_modules/@aws-cdk/aws-amplify-alpha/lib/app.ts:303:12)
    at new CdkStack (/root/cdk/lib/cdk-stack.ts:17:24)
    at Object.<anonymous> (/root/cdk/bin/cdk.ts:7:1)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module.m._compile (/root/cdk/node_modules/ts-node/src/index.ts:1618:23)

Subprocess exited with error 1

Expected Behavior

cdk synth successes

Current Behavior

the above error happens on cdk synth

Reproduction Steps

Run cdk synth with the below code:

import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as amplify from '@aws-cdk/aws-amplify-alpha';
import { Asset } from 'aws-cdk-lib/aws-s3-assets';

export class CdkStack extends cdk.Stack {
  constructor(scope: Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    const asset = new Asset(this, 'Frontend', {
      path: './cdk.json',
    });
    const app = new amplify.App(this, 'MyApp', {
      platform: amplify.Platform.WEB_COMPUTE,
    });
    const branch = app.addBranch('dev', { asset: asset });
  }
}

Possible Solution

No response

Additional Information/Context

#27955 seems related to this. Maybe the relative directory structure differs from the expectation? (given that alpha modules are installed on a special location (node_modules/@aws-cdk/aws-amplify-alpha)

CDK CLI Version

2.110.0

Framework Version

No response

Node.js Version

v18.13.0

OS

macOS

Language

TypeScript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-amplifyRelated to AWS AmplifybugThis issue is a bug.effort/mediumMedium work item – several days of effortp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions