Skip to content

NetworkInterface

Source: src/AWS/EC2/NetworkInterface.ts

An Elastic Network Interface (ENI) — a virtual network card in a VPC subnet with its own private IPs, MAC address, and security groups. Attach one to an instance via a NetworkInterfaceAttachment for stable-IP and multi-homing patterns.

Changing subnetId or the primary privateIpAddress replaces the interface. description, securityGroupIds, and sourceDestCheck are applied in place.

const eni = yield* AWS.EC2.NetworkInterface("AppEni", {
subnetId: subnet.subnetId,
description: "stable IP for the app server",
securityGroupIds: [securityGroup.groupId],
});

The interface gets a private IP from the subnet’s range. Its IP survives instance replacement — detach it from a failed instance and attach it to a new one to keep the same address.

const eni = yield* AWS.EC2.NetworkInterface("FixedIpEni", {
subnetId: subnet.subnetId,
privateIpAddress: "10.0.1.50",
securityGroupIds: [securityGroup.groupId],
});

Pinning privateIpAddress gives the interface a predictable address — useful for appliances and services other resources reference by IP.

const eni = yield* AWS.EC2.NetworkInterface("NatEni", {
subnetId: subnet.subnetId,
sourceDestCheck: false,
securityGroupIds: [securityGroup.groupId],
});

Disable sourceDestCheck when the interface belongs to a NAT instance, firewall, or router that forwards packets not addressed to itself.