Skip to content

CDK v2 seems to have changed plugin exports #37

@Purii

Description

@Purii

Thanks for that awesome plugin!

Unfortunately it doesn't seem to work anymore with recent versions of CDK v2 RC (at least 2.0.0-rc.20).
It seems like some exports aren't available anymore.
After changing some imports the plugin works again.

Error:

Unable to load cdk-multi-profile-plugin: Error: Cannot find module 'aws-cdk'
Require stack:
- /PATHTOREPO/node_modules/cdk-multi-profile-plugin/lib/ini-file-credential-provider-source.js
- /PATHTOREPO/node_modules/cdk-multi-profile-plugin/lib/multi-profile-plugin.js
- /PATHTOREPO/node_modules/cdk-multi-profile-plugin/lib/index.js
- /PATHTOREPO/node_modules/aws-cdk/lib/plugin.js
- /PATHTOREPO/node_modules/aws-cdk/lib/api/aws-auth/credential-plugins.js
- /PATHTOREPO/node_modules/aws-cdk/lib/api/aws-auth/sdk-provider.js
- /PATHTOREPO/node_modules/aws-cdk/lib/api/aws-auth/index.js
- /PATHTOREPO/node_modules/aws-cdk/bin/cdk.js
- /PATHTOREPO/node_modules/aws-cdk/bin/cdk
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:94:18)
    at Object.<anonymous> (/PATHTOREPO/node_modules/cdk-multi-profile-plugin/src/ini-file-credential-provider-source.ts:4:1)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
Unable to load plug-in: cdk-multi-profile-plugin

Working Fix:

// /cdk-multi-profile-plugin/ini-file-credential-provider-source.ts:4
import { CredentialProviderSource, Mode } from "aws-cdk/lib/api/aws-auth/credentials";

// /cdk-multi-profile-plugin/multi-profile-plugin
import { Plugin, PluginHost } from "aws-cdk/lib/plugin";

Are you aware of that? I didn't dig too deep into the CDKv2 Source and not sure if there are any official API Changes for Plugins. If it's fine for you to import the exports directly from the specific files I can create a PR. But an official API would be more solid.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions