Skip to content

Commit 5e2a3ea

Browse files
authored
fix: randomize prefix (#8)
* fix: uniquify the resourcePrefix * fix: try to remove the actual name
1 parent 69bb97f commit 5e2a3ea

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { aws_autoscaling, aws_ec2, aws_iam, aws_kms, Duration } from 'aws-cdk-lib';
1+
import { aws_autoscaling, aws_ec2, aws_iam, aws_kms, Duration, Names } from 'aws-cdk-lib';
22
import { KeyPair } from 'cdk-ec2-key-pair';
33
import { Construct } from 'constructs';
44
import { Namer } from 'multi-convention-namer';
@@ -81,7 +81,11 @@ export class JumpBox extends Construct {
8181
this.keyPair = new KeyPair(this, 'KeyPair', {
8282
name: id.pascal,
8383
kms: props.kmsKey,
84-
resourcePrefix: 'x', // https://github.com/udondan/cdk-ec2-key-pair/issues/53
84+
// What I'd really like to do is remove the function name.
85+
// It provides no value, but causes conflicts
86+
// when you try to deploy more than one jumpbox in a given environment.
87+
// https://github.com/udondan/cdk-ec2-key-pair/issues/53
88+
resourcePrefix: Names.uniqueId(this).slice(-8),
8589
storePublicKey: true,
8690
});
8791
} else {

0 commit comments

Comments
 (0)