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

Issue:
Inconsistent names of name and keyPairName
Hi,

I was confused by the fact that the constructor property for the key name is still called `name`, but the access property is renamed to `keyPairName`. Also the release notes stated that the constructor property was renamed - or have I misunderstood something? It would be nice to have a consistent names to avoid this confusion.

Thanks!


Discussion / hints:
ok, I've misread construct with constructor - nevertheless, the inconsistent names are still confusing IMHO...
I guess you're right. To be more consistent with the core cdk modules, the `name` prop should be renamed `keyPairName`. I think that's how it's done everywhere in the core.

Fix patch:
diff --git a/lib/index.ts b/lib/index.ts
index b9cd9688..c71b14de 100644
--- a/lib/index.ts
+++ b/lib/index.ts
@@ -37,7 +37,7 @@ export interface KeyPairProps extends ResourceProps {
    *
    * The name can be up to 255 characters long. Valid characters include _, -, a-z, A-Z, and 0-9.
    */
-  readonly name: string;
+  readonly keyPairName: string;
 
   /**
    * The description for the key in AWS Secrets Manager
@@ -234,11 +234,11 @@ export class KeyPair extends Construct implements ITaggable {
     const kmsPrivate = props.kmsPrivateKey || props.kms;
     const kmsPublic = props.kmsPublicKey || props.kms;
 
-    const key = new CustomResource(this, `EC2-Key-Pair-${props.name}`, {
+    const key = new CustomResource(this, `EC2-Key-Pair-${props.keyPairName}`, {
       serviceToken: this.lambda.functionArn,
       resourceType: resourceType,
       properties: {
-        Name: props.name,
+        Name: props.keyPairName,
         Description: props.description || '',
         KmsPrivate: kmsPrivate?.keyArn || 'alias/aws/secretsmanager',
         KmsPublic: kmsPublic?.keyArn || 'alias/aws/secretsmanager',


Test patch:
diff --git a/test/lib/test-stack.ts b/test/lib/test-stack.ts
index 672a611c..ae6b618f 100644
--- a/test/lib/test-stack.ts
+++ b/test/lib/test-stack.ts
@@ -15,7 +15,7 @@ export class TestStack extends cdk.Stack {
     cdk.Tags.of(scope).add('Hello', 'World');
 
     const keyPair = new KeyPair(this, 'Test-Key-Pair', {
-      name: 'test-key-pair',
+      keyPairName: 'test-key-pair',
       description: 'A test Key Pair',
       removeKeySecretsAfterDays: 0,
       storePublicKey: false,
@@ -33,7 +33,7 @@ export class TestStack extends cdk.Stack {
     // import public key
 
     const keyPairImport = new KeyPair(this, 'Test-Key-Pair-Import', {
-      name: 'test-key-pair-import',
+      keyPairName: 'test-key-pair-import',
       description: 'A test Key Pair, imported via public key',
       removeKeySecretsAfterDays: 0,
       storePublicKey: false,
@@ -49,7 +49,7 @@ export class TestStack extends cdk.Stack {
     // PEM && CloudFront
 
     const keyPairPem = new KeyPair(this, 'Test-Key-Pair-PEM', {
-      name: 'CFN-signing-key',
+      keyPairName: 'CFN-signing-key',
       exposePublicKey: true,
       storePublicKey: true,
       publicKeyFormat: PublicKeyFormat.PEM,