Package com.pulumi.aws.ec2
Class NetworkInterface
- java.lang.Object
-
- com.pulumi.resources.Resource
-
- com.pulumi.resources.CustomResource
-
- com.pulumi.aws.ec2.NetworkInterface
-
public class NetworkInterface extends com.pulumi.resources.CustomResourceProvides an Elastic network interface (ENI) resource. ## Example Usage
### 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: 1. Comment out `privateIps`, `privateIpList`, `privateIpListEnabled` in your configuration 2. Set the desired `privateIpsCount` (count of the number of secondaries, the primary is not included) 3. Apply to assign the extra IPs 4. Remove `privateIpsCount` and restore your settings from the first step 5. Add the new IPs to your current settings 6. 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: ```sh $ pulumi import aws:ec2/networkInterface:NetworkInterface test eni-e5aa89a3 ```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()); } }
-
-
Constructor Summary
Constructors Constructor Description NetworkInterface(java.lang.String name)NetworkInterface(java.lang.String name, NetworkInterfaceArgs args)NetworkInterface(java.lang.String name, NetworkInterfaceArgs args, com.pulumi.resources.CustomResourceOptions options)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.pulumi.core.Output<java.lang.String>arn()com.pulumi.core.Output<java.util.List<NetworkInterfaceAttachment>>attachments()com.pulumi.core.Output<NetworkInterfaceConnectionTrackingSpecification>connectionTrackingSpecification()com.pulumi.core.Output<java.util.Optional<java.lang.String>>description()com.pulumi.core.Output<java.lang.Boolean>enablePrimaryIpv6()com.pulumi.core.Output<java.util.Optional<NetworkInterfaceEnaSrdSpecification>>enaSrdSpecification()static NetworkInterfaceget(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, NetworkInterfaceState state, com.pulumi.resources.CustomResourceOptions options)Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.com.pulumi.core.Output<java.lang.String>interfaceType()com.pulumi.core.Output<java.lang.Integer>ipv4PrefixCount()com.pulumi.core.Output<java.util.List<java.lang.String>>ipv4Prefixes()com.pulumi.core.Output<java.lang.Integer>ipv6AddressCount()com.pulumi.core.Output<java.util.List<java.lang.String>>ipv6Addresses()com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>>ipv6AddressListEnabled()com.pulumi.core.Output<java.util.List<java.lang.String>>ipv6AddressLists()com.pulumi.core.Output<java.lang.Integer>ipv6PrefixCount()com.pulumi.core.Output<java.util.List<java.lang.String>>ipv6Prefixes()com.pulumi.core.Output<java.lang.String>macAddress()com.pulumi.core.Output<java.lang.String>outpostArn()com.pulumi.core.Output<java.lang.String>ownerId()com.pulumi.core.Output<java.lang.String>privateDnsName()com.pulumi.core.Output<java.lang.String>privateIp()com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>>privateIpListEnabled()com.pulumi.core.Output<java.util.List<java.lang.String>>privateIpLists()com.pulumi.core.Output<java.util.List<java.lang.String>>privateIps()com.pulumi.core.Output<java.lang.Integer>privateIpsCount()com.pulumi.core.Output<java.lang.String>region()com.pulumi.core.Output<java.util.List<java.lang.String>>securityGroups()com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>>sourceDestCheck()com.pulumi.core.Output<java.lang.String>subnetId()com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,java.lang.String>>>tags()com.pulumi.core.Output<java.util.Map<java.lang.String,java.lang.String>>tagsAll()
-
-
-
Constructor Detail
-
NetworkInterface
public NetworkInterface(java.lang.String name)
- Parameters:
name- The _unique_ name of the resulting resource.
-
NetworkInterface
public NetworkInterface(java.lang.String name, NetworkInterfaceArgs args)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.
-
NetworkInterface
public NetworkInterface(java.lang.String name, NetworkInterfaceArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.options- A bag of options that control this resource's behavior.
-
-
Method Detail
-
arn
public com.pulumi.core.Output<java.lang.String> arn()
- Returns:
- ARN of the network interface.
-
attachments
public com.pulumi.core.Output<java.util.List<NetworkInterfaceAttachment>> attachments()
- Returns:
- Configuration block to define the attachment of the ENI. See Attachment below for more details!
-
connectionTrackingSpecification
public com.pulumi.core.Output<NetworkInterfaceConnectionTrackingSpecification> connectionTrackingSpecification()
- Returns:
- Configures the [connection tracking timeouts](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/security-group-connection-tracking.html#connection-tracking-timeouts) for the network interface. See Connection Tracking Specification below for more details.
-
description
public com.pulumi.core.Output<java.util.Optional<java.lang.String>> description()
- Returns:
- Description for the network interface.
-
enaSrdSpecification
public com.pulumi.core.Output<java.util.Optional<NetworkInterfaceEnaSrdSpecification>> enaSrdSpecification()
- Returns:
- 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.
-
enablePrimaryIpv6
public com.pulumi.core.Output<java.lang.Boolean> enablePrimaryIpv6()
- Returns:
- 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.
-
interfaceType
public com.pulumi.core.Output<java.lang.String> interfaceType()
- Returns:
- Type of network interface to create. Set to `efa` for Elastic Fabric Adapter. Changing `interfaceType` will cause the resource to be destroyed and re-created.
-
ipv4PrefixCount
public com.pulumi.core.Output<java.lang.Integer> ipv4PrefixCount()
- Returns:
- Number of IPv4 prefixes that AWS automatically assigns to the network interface.
-
ipv4Prefixes
public com.pulumi.core.Output<java.util.List<java.lang.String>> ipv4Prefixes()
- Returns:
- One or more IPv4 prefixes assigned to the network interface.
-
ipv6AddressCount
public com.pulumi.core.Output<java.lang.Integer> ipv6AddressCount()
- Returns:
- 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 to `true`, you can specify `0` to override this setting.
-
ipv6AddressListEnabled
public com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> ipv6AddressListEnabled()
- Returns:
- Whether `ipv6AddressList` is allowed and controls the IPs to assign to the ENI and `ipv6Addresses` and `ipv6AddressCount` become read-only. Default is `false`.
-
ipv6AddressLists
public com.pulumi.core.Output<java.util.List<java.lang.String>> ipv6AddressLists()
- Returns:
- List of private IPs to assign to the ENI in sequential order.
-
ipv6Addresses
public com.pulumi.core.Output<java.util.List<java.lang.String>> ipv6Addresses()
- Returns:
- 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`.
-
ipv6PrefixCount
public com.pulumi.core.Output<java.lang.Integer> ipv6PrefixCount()
- Returns:
- Number of IPv6 prefixes that AWS automatically assigns to the network interface.
-
ipv6Prefixes
public com.pulumi.core.Output<java.util.List<java.lang.String>> ipv6Prefixes()
- Returns:
- One or more IPv6 prefixes assigned to the network interface.
-
macAddress
public com.pulumi.core.Output<java.lang.String> macAddress()
- Returns:
- MAC address of the network interface.
-
outpostArn
public com.pulumi.core.Output<java.lang.String> outpostArn()
-
ownerId
public com.pulumi.core.Output<java.lang.String> ownerId()
- Returns:
- AWS account ID of the owner of the network interface.
-
privateDnsName
public com.pulumi.core.Output<java.lang.String> privateDnsName()
- Returns:
- Private DNS name of the network interface (IPv4).
-
privateIp
public com.pulumi.core.Output<java.lang.String> privateIp()
-
privateIpListEnabled
public com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> privateIpListEnabled()
- Returns:
- Whether `privateIpList` is allowed and controls the IPs to assign to the ENI and `privateIps` and `privateIpsCount` become read-only. Default is `false`.
-
privateIpLists
public com.pulumi.core.Output<java.util.List<java.lang.String>> privateIpLists()
- Returns:
- List of private IPs to assign to the ENI in sequential order. Requires setting `privateIpListEnabled` to `true`.
-
privateIps
public com.pulumi.core.Output<java.util.List<java.lang.String>> privateIps()
- Returns:
- List of private IPs to assign to the ENI without regard to order.
-
privateIpsCount
public com.pulumi.core.Output<java.lang.Integer> privateIpsCount()
- Returns:
- 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 assigned to an ENI by default.
-
region
public com.pulumi.core.Output<java.lang.String> region()
- Returns:
- Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
-
securityGroups
public com.pulumi.core.Output<java.util.List<java.lang.String>> securityGroups()
- Returns:
- List of security group IDs to assign to the ENI.
-
sourceDestCheck
public com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> sourceDestCheck()
- Returns:
- Whether to enable source destination checking for the ENI. Default true.
-
subnetId
public com.pulumi.core.Output<java.lang.String> subnetId()
- Returns:
- Subnet ID to create the ENI in. The following arguments are optional:
-
tags
public com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,java.lang.String>>> tags()
- Returns:
- Map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
-
tagsAll
public com.pulumi.core.Output<java.util.Map<java.lang.String,java.lang.String>> tagsAll()
- Returns:
- Map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
-
get
public static NetworkInterface get(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, @Nullable NetworkInterfaceState state, @Nullable com.pulumi.resources.CustomResourceOptions options)
Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.- Parameters:
name- The _unique_ name of the resulting resource.id- The _unique_ provider ID of the resource to lookup.state-options- Optional settings to control the behavior of the CustomResource.
-
-