Skip to content

NetworkInterfaceAttachment

Source: src/AWS/EC2/NetworkInterfaceAttachment.ts

Attaches an NetworkInterface (ENI) to an EC2 Instance at a device index. The interface and instance must be in the same Availability Zone. On delete the interface is detached (force-detached as a fallback) before the resource is removed.

This is an existence-style resource — its identity is the networkInterfaceId/instanceId/deviceIndex triple. Changing any of them replaces the attachment.

const attachment = yield* AWS.EC2.NetworkInterfaceAttachment("SecondaryEni", {
networkInterfaceId: eni.networkInterfaceId,
instanceId: instance.instanceId,
deviceIndex: 1,
});

Device index 0 is the instance’s primary interface, so secondary interfaces use index 1 and up. The ENI’s IPs and security groups now apply to the instance on that interface.