Repository: udondan/cdk-ec2-key-pair (language: python)

Issue:
Not Working with CDK v2 Project
SSIA.

CDK v2 is now stable.
https://github.com/aws/aws-cdk/releases/tag/v2.0.0
https://docs.aws.amazon.com/ja_jp/cdk/latest/guide/work-with-cdk-v2.html

```
$ npm install cdk-ec2-key-pair
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: **********@0.1.0
npm ERR! Found: constructs@10.0.9
npm ERR! node_modules/constructs
npm ERR!   constructs@"10.0.9" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer constructs@"^3.2.80" from cdk-ec2-key-pair@2.2.1
npm ERR! node_modules/cdk-ec2-key-pair
npm ERR!   cdk-ec2-key-pair@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /home/******/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/******/.npm/_logs/2021-12-05T08_29_36_474Z-debug.log
```



Discussion / hints:
I found the forked version for CDK v2. And looks good to me.
https://constructs.dev/packages/@twenty8ent/cdk-ec2-key-pair-aws-v2/v/0.0.1?lang=typescript

```
$ npm install @twenty8ent/cdk-ec2-key-pair-aws-v2

added 2 packages, removed 7 packages, and audited 576 packages in 9s

25 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
```

Fix patch:
diff --git a/README.md b/README.md
index 78015b43..444582df 100644
--- a/README.md
+++ b/README.md
@@ -22,29 +22,27 @@ CloudFormation doesn't directly support creation of EC2 Key Pairs. This construc
 
 This package has peer dependencies, which need to be installed along in the expected version.
 
-For TypeScript/NodeJS, add these to your `dependencies` in `package.json`:
+For TypeScript/NodeJS, add these to your `dependencies` in `package.json`. For Python, add these to your `requirements.txt`:
 
 - cdk-ec2-key-pair
-- @aws-cdk/aws-ec2
-- @aws-cdk/aws-iam
-- @aws-cdk/aws-kms
-- @aws-cdk/aws-lambda
+- aws-cdk-lib (^2.0.0)
+- cdk-iam-floyd (^0.300.0)
+- constructs (^10.0.0)
 
-For Python, add these to your `requirements.txt`:
+## CDK compatibility
 
-- cdk-ec2-key-pair
-- aws-cdk.aws-ec2
-- aws-cdk.aws-iam
-- aws-cdk.aws-kms
-- aws-cdk.aws-lambda
+- Version 3.x is compatible with the CDK v2.
+- Version 2.x is compatible with the CDK v1. There won't be regular updates for this.
 
 ## Usage
 
 ```typescript
-import cdk = require('@aws-cdk/core');
-import ec2 = require('@aws-cdk/aws-ec2');
+import cdk = require('aws-cdk-lib');
+import { Construct } from 'constructs';
 import { KeyPair } from 'cdk-ec2-key-pair';
 
+// ...
+
 // Create the Key Pair
 const key = new KeyPair(this, 'A-Key-Pair', {
     name: 'a-key-pair',
@@ -129,6 +127,6 @@ const keyPair = new KeyPair(this, 'A-Key-Pair', {
    [npm]: https://www.npmjs.com/package/cdk-ec2-key-pair
    [PyPI]: https://pypi.org/project/cdk-ec2-key-pair/
    [NuGet]: https://www.nuget.org/packages/CDK.EC2.KeyPair/
-   [docs]: https://awscdk.io/packages/cdk-ec2-key-pair@2.2.1
+   [docs]: https://awscdk.io/packages/cdk-ec2-key-pair@3.0.0
    [source]: https://github.com/udondan/cdk-ec2-key-pair
    [license]: https://github.com/udondan/cdk-ec2-key-pair/blob/master/LICENSE
diff --git a/VERSION b/VERSION
index c043eea7..4a36342f 100644
--- a/VERSION
+++ b/VERSION
@@ -1,1 +1,1 @@
-2.2.1
+3.0.0
diff --git a/lib/index.ts b/lib/index.ts
index d922a7ae..5d9b2a06 100644
--- a/lib/index.ts
+++ b/lib/index.ts
@@ -1,8 +1,9 @@
-import iam = require('@aws-cdk/aws-iam');
-import kms = require('@aws-cdk/aws-kms');
-import lambda = require('@aws-cdk/aws-lambda');
-import cdk = require('@aws-cdk/core');
+import cdk = require('aws-cdk-lib');
+import iam = require('aws-cdk-lib/aws-iam');
+import kms = require('aws-cdk-lib/aws-kms');
+import lambda = require('aws-cdk-lib/aws-lambda');
 import * as statement from 'cdk-iam-floyd';
+import { Construct } from 'constructs';
 import path = require('path');
 
 const resourceType = 'Custom::EC2-Key-Pair';
@@ -104,7 +105,7 @@ export interface KeyPairProps extends cdk.ResourceProps {
 /**
  * An EC2 Key Pair
  */
-export class KeyPair extends cdk.Construct implements cdk.ITaggable {
+export class KeyPair extends Construct implements cdk.ITaggable {
   /**
    * The lambda function that is created
    */
@@ -147,7 +148,7 @@ export class KeyPair extends cdk.Construct implements cdk.ITaggable {
   /**
    * Defines a new EC2 Key Pair. The private key will be stored in AWS Secrets Manager
    */
-  constructor(scope: cdk.Construct, id: string, props: KeyPairProps) {
+  constructor(scope: Construct, id: string, props: KeyPairProps) {
     super(scope, id);
 
     if (
diff --git a/package.json b/package.json
index 3aa30f9b..3ea7aa64 100644
--- a/package.json
+++ b/package.json
@@ -55,28 +55,21 @@
     }
   },
   "devDependencies": {
-    "@aws-cdk/aws-iam": "^1.75.0",
-    "@aws-cdk/aws-kms": "^1.75.0",
-    "@aws-cdk/aws-lambda": "^1.75.0",
-    "@aws-cdk/core": "^1.75.0",
+    "aws-cdk-lib": "^2.0.0",
     "@types/aws-lambda": "^8.10.68",
+    "cdk-iam-floyd": "^0.300.0",
     "@types/node": "14.14.16",
     "aws-lambda": "^1.0.6",
     "aws-sdk": "^2.817.0",
     "jsii": "^1.16.0",
     "jsii-pacmak": "^1.16.0",
     "ts-node": "^9.1.1",
-    "typescript": "~4.1.3"
-  },
-  "dependencies": {
-    "cdk-iam-floyd": "^0.112.1"
+    "typescript": "~4.1.3",
+    "constructs": "^10.0.0"
   },
   "peerDependencies": {
-    "@aws-cdk/aws-iam": "^1.75.0",
-    "@aws-cdk/aws-kms": "^1.75.0",
-    "@aws-cdk/aws-lambda": "^1.75.0",
-    "@aws-cdk/core": "^1.75.0",
-    "cdk-iam-floyd": "^0.112.1",
-    "constructs": "^3.2.80"
+    "aws-cdk-lib": "^2.0.0",
+    "cdk-iam-floyd": "^0.300.0",
+    "constructs": "^10.0.0"
   }
 }


Test patch:
diff --git a/test/bin/test.ts b/test/bin/test.ts
index f04dd606..d549c262 100644
--- a/test/bin/test.ts
+++ b/test/bin/test.ts
@@ -1,7 +1,5 @@
 #!/usr/bin/env node
-import 'source-map-support/register';
-
-import * as cdk from '@aws-cdk/core';
+import cdk = require('aws-cdk-lib');
 
 import { TestStack } from '../lib/test-stack';
 
diff --git a/test/lib/test-stack.ts b/test/lib/test-stack.ts
index 48e26082..b47de1ad 100644
--- a/test/lib/test-stack.ts
+++ b/test/lib/test-stack.ts
@@ -1,9 +1,10 @@
-import * as cdk from '@aws-cdk/core';
+import cdk = require('aws-cdk-lib');
+import { Construct } from 'constructs';
 
 import { KeyPair } from '../../lib';
 
 export class TestStack extends cdk.Stack {
-  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
+  constructor(scope: Construct, id: string, props?: cdk.StackProps) {
     super(scope, id, props);
 
     cdk.Tags.of(scope).add('Hello', 'World');
diff --git a/test/package.json b/test/package.json
index 219c4223..c022b425 100644
--- a/test/package.json
+++ b/test/package.json
@@ -11,16 +11,14 @@
   "devDependencies": {
     "@types/node": "14.14.16",
     "@types/node-forge": "^0.9.6",
-    "aws-cdk": "^1.85.0",
+    "aws-cdk": "^2.0.0",
     "node-forge": "0.10.0",
     "ts-node": "^9.1.1",
     "typescript": "~4.1.3"
   },
   "dependencies": {
-    "@aws-cdk/aws-iam": "1.x",
-    "@aws-cdk/aws-kms": "1.x",
-    "@aws-cdk/aws-lambda": "1.x",
-    "@aws-cdk/core": "1.x",
+    "aws-cdk-lib": "2.x",
+    "cdk-iam-floyd": "0.301.0",
     "cdk-ssm-document": "file:.."
   }
 }