'AWS launch template: A value of 4 for CoreCount is not a valid value for the r5a.xlarge instance type. Valid values are [2] [closed]

I created a launch template from a running graviton instance. While saving the template, I changed the instance type from r5dg.xlarge to r5a.xlarge, and changed the ubuntu AMI to the x86 edition.

When I attempt to launch an instance from this template, I get the following error:

A value of 4 for CoreCount is not a valid value for the r5a.xlarge instance type. Valid values are [2].

There's no place to edit the core count.



Solution 1:[1]

I've faced same issue today, trying to downgrade from t3.xlarge to t3.large, and it seems that it is normal behaviour; as the Launch Template is created with the number of cores from the initial selected type of instance; and its value is not updated when new instance type is selected.

It is not an issue if you go with a more powerful instance, as it will have enough cores for running previous configuration (although you will be not taking profit from new cores availables in your instance); but when downgrading to a less powerful instance, it is a problem and you need to modify this value.

As you pointed, it is not possible to modify CoreCount from AWS Console, so you have to edit it through AWS CLI (updating the CpuOptions property), for instance like:

aws ec2 create-launch-template-version --region YOUR_REGION --launch-template-id YOUR_TEMPLATE_ID --source-version TEMPLATE_VERSION_TO_UPDATE --launch-template-data '{"CpuOptions": {"CoreCount": NUMBER_OF_CORES_TO_USE, "ThreadsPerCore": THREADS_PER_CORE}}'

In your case, NUMBER_OF_CORES_TO_USE should be 2, and THREADS_PER_CORE could be 1 or 2, as you prefer (2 by default). Once modified, it will work again as expected

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Juan Miguel S.