Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(aws-cdk-lib): Changing InstanceType regex values to add hyphen #27614

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1414,7 +1414,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
Loading