pulumi_wasm_providers_aws_mini::ec2

Module network_interface

source
Expand description

Provides an Elastic network interface (ENI) resource.

§Example Usage

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let test = network_interface::create(
        "test",
        NetworkInterfaceArgs::builder()
            .attachments(
                vec![
                    NetworkInterfaceAttachment::builder().deviceIndex(1)
                    .instance("${testAwsInstance.id}").build_struct(),
                ],
            )
            .private_ips(vec!["10.0.0.50",])
            .security_groups(vec!["${web.id}",])
            .subnet_id("${publicA.id}")
            .build_struct(),
    );
}

§Example of Managing Multiple IPs on a Network Interface

By default, private IPs are managed through the private_ips and private_ips_count 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 private_ip_list_enabled to true and use private_ip_list to manage the IPs. This will disable the private_ips and private_ips_count settings, which must be removed from the config file but are still exported. Note that changing the first address of private_ip_list, which is the primary, always requires a new interface.

If you are managing a specific set or list of IPs, instead of just using private_ips_count, this is a potential workflow for also leveraging private_ips_count to have AWS automatically assign additional IP addresses:

  1. Comment out private_ips, private_ip_list, private_ip_list_enabled in your configuration
  2. Set the desired private_ips_count (count of the number of secondaries, the primary is not included)
  3. Apply to assign the extra IPs
  4. Remove private_ips_count 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

Using pulumi import, import Network Interfaces using the id. For example:

$ pulumi import aws:ec2/networkInterface:NetworkInterface test eni-e5aa89a3

Structs§

Functions§

  • Registers a new resource with the given unique name and arguments