Recently I have experienced an interesting situation where an AWS Marketplace AMI, specifically Debian 10, blocked me from upgrading the instance type. In this specific case, the situation did not allow me to simply migrate to a newer version of Debian, so I had to find a workaround. This article will explain how I did it.
So it turns out, AWS Marketplace AMI maintainers can set limitations when it comes to compatibility with instance families and generations. In this specific case, the Debian 10 AMI was not compatible with c6 or c7 instances, so I was stuck on the c5 generation. This is quite unfortunate, because the c5 generation is not the latest one, while it costs the same as the c6 generation. Usually, a newer generation means better performance, so I wanted to upgrade.
The most straightforward way of upgrading an instance is just turning it off and changing the instance type. This is what I tried first, but it did not work. The error message was the following:
"The instance configuration for this AWS Marketplace product is not supported. Please see the AWS Marketplace site for more information about supported instance types, regions, and operating systems."
Since an in-place upgrade did not work, I figured I could simply launch a newer instance type from a new AMI, detach its EBS volume, and attach the old EBS volume to the new instance. This resulted in the same error message as before.
This means the EBS volume is tied to the AMI, and sticks to the limitations of the AMI. Now I had to think on how to get around this.
I figured that a restored snapshot might not have this link to the original AMI, because it is a new EBS volume. So I created a snapshot from the old EBS volume, and created a new EBS volume from the snapshot. I tried to attach it to the newer instance, but sadly I still got the same error message... This means the snapshot also has this link to the original AMI.
The last method I tried was to create a new EBS volume, and copy the data from the old EBS volume to the new one. This is a bit more complicated, but it worked. Here are the steps I took:
lsblk
to see the device name of the EBS volumes. You should be able to identify them by their size, their partitions and their mountpointssudo dd if=/dev/nvme1n1 of=/dev/nvme2n1 bs=1M
to copy the data from the old EBS volume to the new one. Replace /dev/nvme1n1
and /dev/nvme2n1
with the device names of the old and new EBS volumes respectivelyAfter this, you can detach the old EBS volume from the migration instance, and attach the new EBS volume to the original instance. You are now able to change the instance type to a newer generation.
You can verify the instance type by checking the kernel log for the DMI information. In my case, the instance type was c6a.large:
admin@ip-10-0-10-11:/var/log$ grep --binary-files=text 'DMI: Amazon' kern.log
Nov 10 07:18:10 ip-10-0-10-11 kernel: [ 0.000000] DMI: Amazon EC2 c5a.large/, BIOS 1.0 10/16/2017
Nov 10 07:50:32 ip-10-0-10-11 kernel: [ 0.000000] DMI: Amazon EC2 c6a.large/, BIOS 1.0 10/16/2017
The method described above is not without its risks. If you are not careful, you might end up with a corrupted EBS volume, or even worse, a corrupted instance. Here are some things to keep in mind:
Since the AMI used in this article is free, I do not see any issues in using it. However, if you are using any Marketplace AMI, you might want to check the terms and conditions of the AMI before using this method. I am not responsible for any damages caused by using this method.
Overcoming AWS Marketplace AMI limitations, particularly with Debian 10, demanded ingenuity. While direct instance modifications and EBS volume reattachments fell short, a successful method involved creating a new EBS volume and orchestrating a meticulous data copy.
A word of caution: this method carries risks. Safeguard your data with proper backups and ensure meticulous attention to the data copy direction. Remember, the success lies in copying from the old EBS volume to the new one.
In the realm of AWS intricacies, navigating these challenges requires both creativity and caution. Proceed with care, and you might just unlock new possibilities for your instance upgrades.
Remember, each cloud adventure is unique—happy upgrading!