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-autoscaling: The specified instance m7i.xlarge is not valid #28459

Closed
peterrsongg opened this issue Dec 22, 2023 · 6 comments
Closed

aws-autoscaling: The specified instance m7i.xlarge is not valid #28459

peterrsongg opened this issue Dec 22, 2023 · 6 comments
Labels
@aws-cdk/aws-autoscaling Related to Amazon EC2 Auto Scaling bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/medium Medium work item – several days of effort p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@peterrsongg
Copy link

Describe the bug

When trying to create an autoscaling group with instance type m7i.xlarge and machineImage ec2.MachineImage.latestAmazonLinux2023() I receive the following error:

 Deployment failed: Error: The stack named Dev-PerfTests failed creation, 
it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: 
Resource handler returned message: "The specified instance type m7i.xlarge is not valid
 (Service: AutoScaling, Status Code: 400, Request ID: 0d9c9cd9-d2fe-48c7-98f2-ee04a8f93602)"
 (RequestToken: 70bffecd-981f-7ad2-8ebd-f0d7d8730f02, HandlerErrorCode: InvalidRequest),
 Resource handler returned message: "The specified instance type m7i.large is not valid
 (Service: AutoScaling, Status Code: 400, Request ID: 8404beeb-4b40-4afc-878b-8dfd1d3a787f)"
 (RequestToken: 2c522a9e-440f-965a-aca9-3252ef99729e, HandlerErrorCode: InvalidRequest)

Expected Behavior

The autoscaling group is able to be created with m7i.xlarge

Current Behavior

The autoscaling group fails creation with the above error. Interestingly, this same configuration will work in aws-cdk-lib/ec2 and m6i will work if specified in the autoscaling group, but m7I does not

Reproduction Steps

Create an autoscaling group like so:

    const vpc = ec2.Vpc.fromLookup(this, 'VPC', { isDefault: true });
    // lets create a security group for our instance
    // A security group acts as a virtual firewall for your instance to control inbound and outbound traffic.
    const securityGroup = new ec2.SecurityGroup(this, 'simple-instance-1-sg', {
      vpc: vpc,
      allowAllOutbound: true, // will let your instance send outboud traffic
      securityGroupName: 'simple-instance-1-sg',
    });

    const role = new Role(this, 'ec2Role', {
      assumedBy: new ServicePrincipal('ec2.amazonaws.com'),
    });
    role.addManagedPolicy(ManagedPolicy.fromAwsManagedPolicyName('AWSCodeCommitReadOnly'));
    role.addManagedPolicy(ManagedPolicy.fromAwsManagedPolicyName('CloudWatchFullAccess'));
    role.addManagedPolicy(ManagedPolicy.fromAwsManagedPolicyName('AmazonSSMManagedInstanceCore'));

    const autoScalingGroupA = new AutoScalingGroup(this, 'AutoScalingGroupA', {
      vpc: vpc,
      instanceType: ec2.InstanceType.of(ec2.InstanceClass.M6I, ec2.InstanceSize.XLARGE),
      machineImage: ec2.MachineImage.latestAmazonLinux2023(),
      allowAllOutbound: true,
      maxCapacity: 1,
      minCapacity: 0,
      desiredCapacity: 0,
      healthCheck: HealthCheck.ec2(),
      securityGroup: securityGroup,
      role: role,
    });

Possible Solution

No response

Additional Information/Context

aws-cdk-lib version: 2.115.0
constructs: 10.3.0

CDK CLI Version

2.115

Framework Version

No response

Node.js Version

14.21.3

OS

Amazon Linux

Language

TypeScript

Language Version

Typescript (5.0.4)

Other information

No response

@peterrsongg peterrsongg added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 22, 2023
@github-actions github-actions bot added the @aws-cdk/aws-autoscaling Related to Amazon EC2 Auto Scaling label Dec 22, 2023
@pahud pahud self-assigned this Dec 22, 2023
@pahud
Copy link
Contributor

pahud commented Dec 22, 2023

Are you able to select that instance type from AWS EC2 console?
Which region are you deploying to?
I am afraid the instance type might not be available in your region.

I am able to deploy m7x.large in us-east-1 with the CDK code below:

// get autoscaling group
export function getAutoScalingGroup(scope: Construct, instanceType?: ec2.InstanceType, machineImage?: ec2.MachineImage): autoscaling.AutoScalingGroup {
    return new autoscaling.AutoScalingGroup(scope, 'AutoScalingGroup', {
        instanceType: instanceType ?? ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.LARGE),
        machineImage: new ec2.AmazonLinuxImage({ generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2023 }),
        vpc: getDefaultVpc(scope),
    })
}

export class DemoStack extends MyStack {
  constructor(scope: Construct, id: string, props: StackProps) {
    super(scope, id, props);

   getAutoScalingGroup(this, new ec2.InstanceType('m7i.xlarge'))
  }
}

And I saw this in my synthesized launch template

  "AutoScalingGroupLaunchTemplateCE2B3AFE": {
   "Type": "AWS::EC2::LaunchTemplate",
   "Properties": {
    "LaunchTemplateData": {
     "IamInstanceProfile": {
      "Arn": {
       "Fn::GetAtt": [
        "AutoScalingGroupInstanceProfile342FAC7C",
        "Arn"
       ]
      }
     },
     "ImageId": {
      "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestal2023amikernel61x8664C96584B6F00A464EAD1953AFF4B05118Parameter"
     },
     "InstanceType": "m7i.xlarge",
     "Monitoring": {
      "Enabled": false
     },

@pahud pahud added p2 effort/medium Medium work item – several days of effort labels Dec 22, 2023
@pahud pahud removed their assignment Dec 22, 2023
@pahud pahud added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Dec 22, 2023
Copy link

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Dec 24, 2023
@MADDY312
Copy link

MADDY312 commented Feb 6, 2024

I am trying to switch from t2.small to c7a.medium/m7a.medium, It throws the same error, but when trying to switch from t2.small to c5a.large, it works fine. And my region is us-east-1. Has anybody found any solution to this?

@whalesalad
Copy link

Having this issue w/ Terraform, too. Trying to move an autoscaling lauch configuration from m6i.4xlarge to m7i.4xlarge and it won't work. I can't even create a new one.

╷
│ Error: creating Auto Scaling Launch Configuration (T3-Production20240228001640217100000002): ValidationError: The specified instance type m7i.4xlarge is not valid
│ 	status code: 400, request id: fab5d572-c4fe-4d8c-8193-5ca60f02d30c
│
│   with aws_launch_configuration.titan_m7i,
│   on ec2_launch_configuration.tf line 52, in resource "aws_launch_configuration" "titan_m7i":
│   52: resource "aws_launch_configuration" "titan_m7i" {
│
╵

@logrus1
Copy link

logrus1 commented Apr 12, 2024

I ran into this issue today and couldn't find the solution anywhere. Wish they made the error more clear. For me it was because I was still using AutoScaling Launch configurations instead of launch templates.

"EC2 Auto Scaling no longer supports new EC2 features or new EC2 instance types released after December 31, 2022 through launch configurations. We recommended that you use launch templates to create new Auto Scaling groups and migrate any existing launch configurations to launch templates."

I use cloud formation so I had to replace my AWS::AutoScaling::LaunchConfiguration resource with an AWS::EC2::LaunchTemplate resource and update my autoscaling group. So not an issue with the cdk, just an issue of trying to create/update a deprecated resource using an instance type newer than 2022.

@craiga
Copy link

craiga commented Jul 12, 2024

Thank you @logrus1 ! I was having this issue using Elastic Beanstalk, which must be using that old style resource in the background.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-autoscaling Related to Amazon EC2 Auto Scaling bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/medium Medium work item – several days of effort p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

6 participants