aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.52k stars 3.86k forks source link

aws-cdk/lambda-layer-kubectl-v27: Found CDK v1 deps in your project, even though your "cdkVersion" is 2.x. #28628

Open lmouhib opened 8 months ago

lmouhib commented 8 months ago

Describe the bug

When using kubectl layers for newer version, CDK complain that the layer still uses CDK V1.

Expected Behavior

CDk should not complain and the lambda layer library should use CDK v2

Current Behavior

CDk should not complain and the lambda layer library seems to use CDK v1.

๐Ÿ‘พ default | ts-node --skip-project .projenrc.ts
๐Ÿ‘พ WARNING: Found CDK v1 deps in your project, even though your "cdkVersion" is 2.x: [@aws-cdk/lambda-layer-kubectl-v27]. Check out https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html for more information about using CDK v2 dependencies.
๐Ÿ‘พ Installing dependencies...
๐Ÿ‘พ install | yarn install --check-files

Reproduction Steps

Create an EKS cluster with L2 module and pass the lambda layer of any EKS after 1.21.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.118.0

Framework Version

No response

Node.js Version

v18.18.0

OS

macOS

Language

TypeScript

Language Version

4.9.4

Other information

No response

pahud commented 8 months ago

According to this the v27 module should depends on cdkVersion 2.28.0

https://github.com/cdklabs/awscdk-asset-kubectl/blob/193965eb3a3cd604ad27c79b159a9b4d5b87213b/.projenrc.ts#L14

Are you running projen in your current project with your own .projenrc.ts? I am not sure if this warning is coming from the layer. What is the cdkVersion in your .projenrc.ts ?

lmouhib commented 8 months ago

@pahud here is the .projenrc.ts link.

We also get the warning if we run a cdk deploy, without using any projen helpers.

kaprah commented 6 months ago

We have this same issue within our internal CDK library as well whenever we are compiling the project, an older version of kubectl layer, but we also did run into the same issue of it complaining about v27, and v28 if those are added as well.

๐Ÿ‘พ build ยป default | node .projenrc.js
๐Ÿ‘พ WARNING: Found CDK v1 deps in your project, even though your "cdkVersion" is 2.x: [@aws-cdk/lambda-layer-kubectl-v26]. Check out https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html for more information about using CDK v2 dependencies.
๐Ÿ‘พ build ยป compile | jsii --silence-warnings=reserved-word

Snippet of our projenrc file with its CDK dependencies:

    cdkVersion: '2.113.0',
    version: '0.1.0',
    gitignore: [
        'test-reports/*',
    ],
    prettier: false,

    /* JsiiProjectOptions */
    authorOrganization: true, /* undefined */
    compat: true, /* Automatically run API compatibility test against the latest version published to npm after compilation. */
    docgen: false, /* Automatically generate API.md from jsii. */
    docsDirectory: 'docs',
    compileBeforeTest: true,
    eslint: true, /* Install eslint. */
    eslintOptions: {
        dirs: ['src', 'test'],
        fileExtensions: ['.ts'],
        tsconfigPath: './tsconfig.dev.json',
        noUnusedLocals: false,
        ignorePatterns: ['.js', '.d.ts', 'node_modules/', '*.generated.ts', 'coverage', '.json', 'src/*/tsconfig.json'],
    },
    jest: true, /* Use jest for unit tests. */

    /* NodeProjectCommonOptions */
    antitamper: false, /* Checks that after build there are no modified files on git. */
    buildWorkflow: true, /* Define a GitHub workflow for building PRs. */
    defaultReleaseBranch: 'main', /* The name of the main release branch. */
    majorVersion: 4,
    // cdkDependenciesAsDeps: false, not used with cdk 2.x
    peerDeps: [
        'aws-cdk-lib@^2.113.0',
        'constructs@^10.0.0',
        '@aws-cdk/lambda-layer-kubectl-v26@^2.0.1',
    ],
    devDeps: [
        '@types/jest',
        'aws-cdk-lib@^2.113.0',
        'constructs@^10.0.0',
        'typescript@~3.9.0',
        'cdk@^2.113.0',
        'typedoc@^0.23',
    ],