NetworkInterface class
Provides an Elastic network interface (ENI) resource.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const test = new aws.ec2.NetworkInterface("test", {
attachments: [{
instance: testAwsInstance.id,
deviceIndex: 1,
}],
subnetId: publicA.id,
privateIps: ["10.0.0.50"],
securityGroups: [web.id],
});
import pulumi
import pulumi_aws as aws
test = aws.ec2.NetworkInterface("test",
attachments=[{
"instance": test_aws_instance["id"],
"device_index": 1,
}],
subnet_id=public_a["id"],
private_ips=["10.0.0.50"],
security_groups=[web["id"]])
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var test = new Aws.Ec2.NetworkInterface("test", new()
{
Attachments = new[]
{
new Aws.Ec2.Inputs.NetworkInterfaceAttachmentArgs
{
Instance = testAwsInstance.Id,
DeviceIndex = 1,
},
},
SubnetId = publicA.Id,
PrivateIps = new[]
{
"10.0.0.50",
},
SecurityGroups = new[]
{
web.Id,
},
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/ec2"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := ec2.NewNetworkInterface(ctx, "test", &ec2.NetworkInterfaceArgs{
Attachments: ec2.NetworkInterfaceAttachmentTypeArray{
&ec2.NetworkInterfaceAttachmentTypeArgs{
Instance: pulumi.Any(testAwsInstance.Id),
DeviceIndex: pulumi.Int(1),
},
},
SubnetId: pulumi.Any(publicA.Id),
PrivateIps: pulumi.StringArray{
pulumi.String("10.0.0.50"),
},
SecurityGroups: pulumi.StringArray{
web.Id,
},
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
resource "aws_ec2_networkinterface" "test" {
attachments {
instance = testAwsInstance.id
device_index = 1
}
subnet_id = publicA.id
private_ips = ["10.0.0.50"]
security_groups = [web.id]
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.NetworkInterface;
import com.pulumi.aws.ec2.NetworkInterfaceArgs;
import com.pulumi.aws.ec2.inputs.NetworkInterfaceAttachmentArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var test = new NetworkInterface("test", NetworkInterfaceArgs.builder()
.attachments(NetworkInterfaceAttachmentArgs.builder()
.instance(testAwsInstance.id())
.deviceIndex(1)
.build())
.subnetId(publicA.id())
.privateIps("10.0.0.50")
.securityGroups(web.id())
.build());
}
}
resources:
test:
type: aws:ec2:NetworkInterface
properties:
attachments:
- instance: ${testAwsInstance.id}
deviceIndex: 1
subnetId: ${publicA.id}
privateIps:
- 10.0.0.50
securityGroups:
- ${web.id}
Example of Managing Multiple IPs on a Network Interface
By default, private IPs are managed through the privateIps and privateIpsCount arguments which manage IPs as a set of IPs that are configured without regard to order. For a new network interface, the same primary IP address is consistently selected from a given set of addresses, regardless of the order provided. However, modifications of the set of addresses of an existing interface will not alter the current primary IP address unless it has been removed from the set.
In order to manage the private IPs as a sequentially ordered list, configure privateIpListEnabled to true and use privateIpList to manage the IPs. This will disable the privateIps and privateIpsCount settings, which must be removed from the config file but are still exported. Note that changing the first address of privateIpList, which is the primary, always requires a new interface.
If you are managing a specific set or list of IPs, instead of just using privateIpsCount, this is a potential workflow for also leveraging privateIpsCount to have AWS automatically assign additional IP addresses:
- Comment out
privateIps,privateIpList,privateIpListEnabledin your configuration - Set the desired
privateIpsCount(count of the number of secondaries, the primary is not included) - Apply to assign the extra IPs
- Remove
privateIpsCountand restore your settings from the first step - Add the new IPs to your current settings
- Apply again to update the stored state
This process can also be used to remove IP addresses in addition to the option of manually removing them. Adding IP addresses in a manually is more difficult because it requires knowledge of which addresses are available.
Import
Identity Schema
Required
id(String) ID of the network interface.
Optional
accountId(String) AWS Account where this resource is managed.region(String) Region where this resource is managed.
Using pulumi import, import Network Interfaces using the id. For example:
$ pulumi import aws:ec2/networkInterface:NetworkInterface test eni-e5aa89a3
Constructors
- NetworkInterface(String name, {NetworkInterfaceArgs? args, CustomResourceOptions? options})
-
Creates a new NetworkInterface.
nameThe Pulumi resource name.argsArguments used to configure this NetworkInterface. The set of arguments for NetworkInterface.optionsResource options controlling this resource's behavior. - NetworkInterface.reference(String urn)
- Creates a typed reference to an existing NetworkInterface resource.
Properties
-
arn
↔ Output<
String> -
ARN of the network interface.
latefinal
-
attachments
↔ Output<
List< NetworkInterfaceAttachment> > -
Configuration block to define the attachment of the ENI. See Attachment below for more details!
latefinal
-
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
description
↔ Output<
String?> -
Description for the network interface.
latefinal
-
enablePrimaryIpv6
↔ Output<
bool> -
Enables assigning a primary IPv6 Global Unicast Address (GUA) to the network interface (ENI) in dual-stack or IPv6-only subnets. This ensures the instance attached to the ENI retains a consistent IPv6 address. Once enabled, the first IPv6 GUA becomes the primary IPv6 address and cannot be disabled. The primary IPv6 address remains assigned until the instance is terminated or the ENI is detached. Enabling and subsequent disabling forces recreation of the ENI.
latefinal
-
enaSrdSpecification
↔ Output<
NetworkInterfaceEnaSrdSpecification?> -
Configures ENA Express for the network interface. The ENI must be attached to an instance to configure ENA Express. See ENA SRD Specification below for more details.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
-
interfaceType
↔ Output<
String> -
Type of network interface to create. Set to
efafor Elastic Fabric Adapter. ChanginginterfaceTypewill cause the resource to be destroyed and re-created.latefinal -
ipv4PrefixCount
↔ Output<
int> -
Number of IPv4 prefixes that AWS automatically assigns to the network interface.
latefinal
-
ipv4Prefixes
↔ Output<
List< String> > -
One or more IPv4 prefixes assigned to the network interface.
latefinal
-
ipv6AddressCount
↔ Output<
int> -
Number of IPv6 addresses to assign to a network interface. You can't use this option if specifying specific
ipv6Addresses. If your subnet has the AssignIpv6AddressOnCreation attribute set totrue, you can specify0to override this setting.latefinal -
ipv6Addresses
↔ Output<
List< String> > -
One or more specific IPv6 addresses from the IPv6 CIDR block range of your subnet. Addresses are assigned without regard to order. You can't use this option if you're specifying
ipv6AddressCount.latefinal -
ipv6AddressListEnabled
↔ Output<
bool?> -
Whether
ipv6AddressListis allowed and controls the IPs to assign to the ENI andipv6Addressesandipv6AddressCountbecome read-only. Default isfalse.latefinal -
ipv6AddressLists
↔ Output<
List< String> > -
List of private IPs to assign to the ENI in sequential order.
latefinal
-
ipv6PrefixCount
↔ Output<
int> -
Number of IPv6 prefixes that AWS automatically assigns to the network interface.
latefinal
-
ipv6Prefixes
↔ Output<
List< String> > -
One or more IPv6 prefixes assigned to the network interface.
latefinal
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
macAddress
↔ Output<
String> -
MAC address of the network interface.
latefinal
-
outpostArn
↔ Output<
String> -
latefinal
-
ownerId
↔ Output<
String> -
AWS account ID of the owner of the network interface.
latefinal
-
privateDnsName
↔ Output<
String> -
Private DNS name of the network interface (IPv4).
latefinal
-
privateIp
↔ Output<
String> -
latefinal
-
privateIpListEnabled
↔ Output<
bool?> -
Whether
privateIpListis allowed and controls the IPs to assign to the ENI andprivateIpsandprivateIpsCountbecome read-only. Default isfalse.latefinal -
privateIpLists
↔ Output<
List< String> > -
List of private IPs to assign to the ENI in sequential order. Requires setting
privateIpListEnabledtotrue.latefinal -
privateIps
↔ Output<
List< String> > -
List of private IPs to assign to the ENI without regard to order.
latefinal
-
privateIpsCount
↔ Output<
int> -
Number of secondary private IPs to assign to the ENI. The total number of private IPs will be 1 +
privateIpsCount, as a primary private IP will be assiged to an ENI by default.latefinal -
region
↔ Output<
String> -
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
securityGroups
↔ Output<
List< String> > -
List of security group IDs to assign to the ENI.
latefinal
-
sourceDestCheck
↔ Output<
bool?> -
Whether to enable source destination checking for the ENI. Default true.
latefinal
-
subnetId
↔ Output<
String> -
Subnet ID to create the ENI in.
latefinal
-
Map of tags to assign to the resource. If configured with a provider
defaultTagsconfiguration block present, tags with matching keys will overwrite those defined at the provider-level.latefinal -
Map of tags assigned to the resource, including those inherited from the provider
defaultTagsconfiguration block.latefinal -
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
urn
↔ Output<
String> -
latefinalinherited
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
get(
String name, Input< String> id, {NetworkInterfaceState? state, CustomResourceOptions? options}) → NetworkInterface -
Gets an existing NetworkInterface resource's state with the given
nameandid.