Home > Enterprise >  Attaching ENI on eth0 on EC2 instance startup
Attaching ENI on eth0 on EC2 instance startup

Time:02-13

I need to attach a static private IP to an instance in an ASG. Since I can't specify it in the Launch Template, I'm using a user-data script to attach an existing ENI on instance startup. It works fine with --device-index 1 but then I get a total of two IPs.

Why is it not possible to have --device-index 0 to attach only the IP address I need?

CodePudding user response:

According to the AWS Certified Solutions Architect Study Guide,

  1. "Every instance must have a primary network interface"
  2. "You can't remove the primary ENI from an instance, and you can't change its subnet."

My best guess is that by the time you run your user-data script, you already have a primary network interface attached.

  • Related