Skip to content

Commit

Permalink
Changing InstanceType regex values to add hyphen
Browse files Browse the repository at this point in the history
  • Loading branch information
Bibhu Pala committed Oct 19, 2023
1 parent 1f7075f commit 9effc6b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-ec2/lib/instance-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ export class InstanceType {
}

public sameInstanceClassAs(other: InstanceType): boolean {
const instanceClass: RegExp = /^([a-z]+\d{1,2}[a-z]*)\.([a-z0-9]+)$/;
const instanceClass: RegExp = /^([a-z-]+\d{1,2}[a-z-]*)\.([a-z0-9-]+)$/;
const instanceClassId = this.instanceTypeIdentifier.match(instanceClass);
const otherInstanceClassId = other.instanceTypeIdentifier.match(instanceClass);
if (instanceClassId == null || otherInstanceClassId == null) {
Expand Down
9 changes: 9 additions & 0 deletions packages/aws-cdk-lib/aws-ec2/test/instance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,15 @@ test('sameInstanceClassAs compares identical InstanceTypes correctly', () => {
expect(sameInstanceType.sameInstanceClassAs(comparitor)).toBeTruthy();
});

test('sameInstanceClassAs compares identical InstanceTypes correctly', () => {
// GIVEN
const comparitor = InstanceType.of(InstanceClass.M7I_FLEX, InstanceSize.LARGE);
//WHEN
const instanceType = new InstanceType('m7i-flex.large');
//THEN
expect(instanceType.sameInstanceClassAs(comparitor)).toBeTruthy();
});

test('sameInstanceClassAs compares InstanceTypes correctly regardless of size', () => {
// GIVEN
const comparitor = InstanceType.of(InstanceClass.T3, InstanceSize.LARGE);
Expand Down

0 comments on commit 9effc6b

Please sign in to comment.