question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ryparkercommented, Oct 20, 2021

The fix has been merged and will be available in the next CDK release.

1reaction
ryparkercommented, Oct 20, 2021

Hey @chu-yik 👋🏻

Thanks for bringing this to our attention.

I’ve labeled this as p1 which means it has been prioritized as important, although please keep in mind that we do have a large number of issues at the moment. It may be some time before we are able to solve this particular issue. We use +1s to help us prioritize our work, and as always we are happy to take contributions if anyone is interested to pick this up and submit a PR.

Bug was introduced by this PR: https://github.com/aws/aws-cdk/pull/16657 Note: There must have been some monocdk configuration missed when @aws-cdk/lambda-layer-node-proxy-agent was added as a dependency of the @aws-cdk/aws-eks package.

Read more comments on GitHub >

github_iconTop Results From Across the Web

aws-cdk/aws-eks module - AWS Documentation
Creating a new cluster is done using the Cluster or FargateCluster ... To connect a self-managed node group to an imported cluster, use...
Read more >
Getting Started - Amazon EKS Blueprints Quick Start
This code will deploy a new EKS Cluster and install the ArgoCD addon. import 'source-map-support/register'; import * as cdk from 'aws-cdk-lib'; import *...
Read more >
EKS cluster deployment always fails at Custom::AWSCDK ...
I'm trying to create an EKS cluster utilizing the existing VPC and subnets in the following way. import { aws_ec2, aws_eks, Stack, ...
Read more >
AWS EKS 101: Creating a Cluster and Deploying an App
First, we will import the necessary libraries from the AWS CDK, including the aws_eks and core modules. We will then create a new...
Read more >
Create EKS cluster - AWS Workshop Studio
Define an EKS cluster by instantiating the imported package. Please copy and paste the code in the following code block right after the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found