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

aws-cdk-lib/aws-ec2: "Malformed instance type identifier" when creating ec2 instance of type 'm7i-flex.large' #27587

Closed
matt-mclaughlin-quantum-si opened this issue Oct 17, 2023 · 6 comments · Fixed by #28040
Assignees
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud bug This issue is a bug. effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md p2

Comments

@matt-mclaughlin-quantum-si

Describe the bug

I'm trying to add an m7i-flex.large instance to a managed node group per
createManagedComputeNodes( name, subnet, [ new ec2.InstanceType('m7i-flex.large'), ], eks.CapacityType.SPOT, );

But receive a Malformed instance type identifier when doing so.

Expected Behavior

I'm able to add the m7i-flex.large instance type as an instance choice for the managed node group

Current Behavior

Error: Malformed instance type identifier
    at InstanceType.sameInstanceClassAs (/node_modules/aws-cdk-lib/aws-ec2/lib/instance-types.js:1:17751)
    at /node_modules/aws-cdk-lib/aws-eks/lib/managed-nodegroup.js:1:7443
    at Array.some (<anonymous>)
    at isGpuInstanceType (/node_modules/aws-cdk-lib/aws-eks/lib/managed-nodegroup.js:1:7422)
    at typeToArch (/node_modules/aws-cdk-lib/aws-eks/lib/managed-nodegroup.js:1:8182)
    at Array.map (<anonymous>)
    at getPossibleAmiTypes (/node_modules/aws-cdk-lib/aws-eks/lib/managed-nodegroup.js:1:8442)
    at new Nodegroup (/node_modules/aws-cdk-lib/aws-eks/lib/managed-nodegroup.js:1:3543)
    at Cluster.addNodegroupCapacity (/node_modules/aws-cdk-lib/aws-eks/lib/cluster.js:1:19557)

Node.js v20.5.0

Reproduction Steps

Add a m7i-flex.large instance type to a managed node group per "Describe the bug". Then run cdk synthesize.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.101.1 (build 16ddad1)

Framework Version

No response

Node.js Version

20.5.0

OS

MAC OS Monterey 12.6.1

Language

TypeScript

Language Version

No response

Other information

No response

@matt-mclaughlin-quantum-si matt-mclaughlin-quantum-si added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 17, 2023
@github-actions github-actions bot added the @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud label Oct 17, 2023
@peterwoodworth
Copy link
Contributor

The regex doesn't allow for hyphens, ths would need to change

const instanceClass: RegExp = /^([a-z]+\d{1,2}[a-z]*)\.([a-z0-9]+)$/;

@peterwoodworth peterwoodworth added good first issue Related to contributions. See CONTRIBUTING.md p2 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Oct 17, 2023
@bibhu107
Copy link

I would like to contribute here!
Thanks

@scanlonp
Copy link
Contributor

@matt-mclaughlin-quantum-si would defining it by ec2.InstanceType.of(ec2.InstanceClass.M7I_FLEX, ec2.InstanceSize.LARGE) work? That looks like the preferred instantiation.

@matt-mclaughlin-quantum-si
Copy link
Author

@matt-mclaughlin-quantum-si would defining it by ec2.InstanceType.of(ec2.InstanceClass.M7I_FLEX, ec2.InstanceSize.LARGE) work? That looks like the preferred instantiation.

@scanlonp Went ahead and tested with that method, but it produces the same result

@jsamuel1
Copy link

This also affects calling the architecture property of instance type, when constructed with the string 'm7i-flex'.

// repo aws-cdk-lib 2.115.0, typescript:
var instanceType = new ec2.InstanceType('m7i-flex.xlarge');
var cpuArch : string = instanceType.architecture;
console.log(`cpuArch: ${cpuArch}`);

Compiler Output:

Error: Malformed instance type identifier
    at InstanceType.get architecture [as architecture] (XXXX/node_modules/aws-cdk-lib/aws-ec2/lib/instance-types.js:1:18931)

@mergify mergify bot closed this as completed in #28040 Jan 30, 2024
mergify bot pushed a commit that referenced this issue Jan 30, 2024
…ontains dashes (#28040)

Fix the Ec2 instance class regular expression to accept values that contains dashes like (m7i-flex, and metal-48xl).

Closes #27587.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

SankyRed pushed a commit that referenced this issue Feb 8, 2024
…ontains dashes (#28040)

Fix the Ec2 instance class regular expression to accept values that contains dashes like (m7i-flex, and metal-48xl).

Closes #27587.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud bug This issue is a bug. effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md p2
Projects
None yet
6 participants