Rash
Rash

Reputation: 8187

AMI not enabled for ENA

I am trying to shrink the root volume of an AMI (ami-0a6b7e0cc0b1f464f) in us-east-1 region. The shrinking itself is successful i.e. I have created a smaller snapshot which works correctly. But when I create an AMI from this snapshot, the instances of that AMI does not have ENA (Enhanced Networking with the Elastic Network Adapter) enabled in it.

Below are the high level steps I performed.

enter image description here

As per AWS Docs

Amazon Linux 2 and the latest versions of the Amazon Linux AMI have the module required for enhanced networking installed and have the required enaSupport attribute set. Therefore, if you launch an instance with an HVM version of Amazon Linux on a supported instance type, enhanced networking is already enabled for your instance.

So if I am using Amazon Linux 2, and I am taking a snapshot of a volume that has all files copied from its previous volume, why is ENA not enabled? Probably networking components are applied some other way so simple copy does not work?

Upvotes: 1

Views: 5752

Answers (2)

Adil Hindistan
Adil Hindistan

Reputation: 6605

So if I am using Amazon Linux 2, and I am taking a snapshot of a volume that has all files copied from its previous volume, why is ENA not enabled? Probably networking components are applied some other way so simple copy does not work?

You can consider AMI as a definition file which includes information about ENA. Snapshots do not know about AMI, they are 'storage'. Yes, they may include a file system, OS, drivers etc but that's not necessarily including the information AWS need to give you what you want == ENA enabled networking. The solution is actually simple. When you are creating an AMI, you tell AWS to enable ENA. As an example if you are using AWS cli to register an image, simply add --ena-support as in

aws ec2 register-image --ena-support ...

Now, AWS does say that if you create an AMI from an instance has ENA enabled, they will automatically infer this information from running instance. However, that's different than using a snapshot to create the image. It worked for you finally b/c you had a running instance with ENA drivers installed and AWS was able to detect it.

Upvotes: 1

Rash
Rash

Reputation: 8187

I still don't know the logical reasoning behind this, but the way I successfully produced an AMI which has ENA enabled is by:

  1. First creating a target volume as mentioned in my question.
  2. Then to stop and detach all volumes (including the root volume) from the EC2 instance that I used to create the target volume. Note that this instance had ENA enabled.
  3. Attach the target volume as root and start the EC2 instance. Since the target volume contains the same files as root, the ec2 instance should have no issues starting up. What we essentially did here was to swap the root volume with target volume.
  4. Verify ENA is enabled on the machine, and your volume size is shrunk. Then create an AMI from the running instance (right click -> image -> create image).

Upvotes: 1

Related Questions