Skip to content

(monocdk/aws-eks, CDKv2): error when building EKS cluster with monocdk import #17061

@chu-yik

Description

@chu-yik

What is the problem?

When using monocdk/aws-eks to build a stack containing an EKS cluster, error is thrown about missing lambda-layer-node-proxy-agent/layer/package.json. This started happening on monocdk 1.126+

it looks like the package.json is not copied by monocdk (comparing to directly importing aws-cdk/aws-eks).

Reproduction Steps

(with monocdk 1.126+)

import {
  DeploymentEnvironment,
  DeploymentStack,
  SoftwareType,
} from '@amzn/pipelines';
import { App } from 'monocdk';
import { Cluster, KubernetesVersion } from 'monocdk/aws-eks'

export interface ClusterStackProps {
  readonly env: DeploymentEnvironment;
}

export class ClusterStack extends DeploymentStack {
  readonly cluster: Cluster;

  constructor(parent: App, id: string, props: ClusterStackProps) {
    super(parent, id, {
      env: props.env,
      softwareType: SoftwareType.INFRASTRUCTURE,
    });

    this.cluster = new Cluster(this, 'ManagementCluster', {
      version: KubernetesVersion.V1_21
    });
  }
}

This stack when build produces an error

What did you expect to happen?

I expect the above stack can be built using monocdk 1.126+

What actually happened?

an error is thrown

sample error log:

------------ app build complete => starting cdk synth -------------
Using cdk out from cdk.json: /local/home/chumich/workplace/TestRoverInfrastructure/src/TestRoverInfrastructureCDK/build/cdk.out
internal/fs/utils.js:332
    throw err;
    ^

Error: ENOENT: no such file or directory, open '/local/home/chumich/workplace/TestRoverInfrastructure/src/TestRoverInfrastructureCDK/node_modules/monocdk/lib/lambda-layer-node-proxy-agent/layer/package.json'
    at Object.openSync (fs.js:497:3)
    at Object.readFileSync (fs.js:393:35)
    at hashFile (/local/home/chumich/workplace/TestRoverInfrastructure/src/TestRoverInfrastructureCDK/node_modules/monocdk/lib/lambda-layer-node-proxy-agent/lib/node-proxy-agent-layer.js:35:20)
    at new NodeProxyAgentLayer (/local/home/chumich/workplace/TestRoverInfrastructure/src/TestRoverInfrastructureCDK/node_modules/monocdk/lib/lambda-layer-node-proxy-agent/lib/node-proxy-agent-layer.js:23:28)
    at new ClusterResourceProvider (/local/home/chumich/workplace/TestRoverInfrastructure/src/TestRoverInfrastructureCDK/node_modules/monocdk/lib/aws-eks/lib/cluster-resource-provider.js:34:31)
    at Function.getOrCreate (/local/home/chumich/workplace/TestRoverInfrastructure/src/TestRoverInfrastructureCDK/node_modules/monocdk/lib/aws-eks/lib/cluster-resource-provider.js:63:85)
    at new ClusterResource (/local/home/chumich/workplace/TestRoverInfrastructure/src/TestRoverInfrastructureCDK/node_modules/monocdk/lib/aws-eks/lib/cluster-resource.js:28:78)
    at new Cluster (/local/home/chumich/workplace/TestRoverInfrastructure/src/TestRoverInfrastructureCDK/node_modules/monocdk/lib/aws-eks/lib/cluster.js:414:50)
    at new ClusterStack (/local/home/chumich/workplace/TestRoverInfrastructure/src/TestRoverInfrastructureCDK/dist/lib/stack/cluster.js:17:24)
    at Object.<anonymous> (/local/home/chumich/workplace/TestRoverInfrastructure/src/TestRoverInfrastructureCDK/dist/lib/app.js:37:22) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/local/home/chumich/workplace/TestRoverInfrastructure/src/TestRoverInfrastructureCDK/node_modules/monocdk/lib/lambda-layer-node-proxy-agent/layer/package.json'
}

CDK CLI Version

1.128.0

Framework Version

No response

Node.js Version

v14.17.0

OS

Mac, and AmazonLinux2

Language

Typescript

Language Version

TypeScript (4.0.5)

Other information

No response

Metadata

Metadata

Labels

@aws-cdk/aws-eksRelated to Amazon Elastic Kubernetes Serviceaws-cdk-libRelated to the aws-cdk-lib packagebugThis issue is a bug.effort/smallSmall work item – less than a day of effortmonocdkRelated to the monocdk packagep0

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions