1. Packages
  2. AWS Classic
  3. API Docs
  4. ec2
  5. getNetworkInterfaces

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi

aws.ec2.getNetworkInterfaces

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi

    Example Usage

    The following shows outputting all network interface ids in a region.

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    export = async () => {
        const example = await aws.ec2.getNetworkInterfaces({});
        return {
            example: example.ids,
        };
    }
    
    import pulumi
    import pulumi_aws as aws
    
    example = aws.ec2.get_network_interfaces()
    pulumi.export("example", example.ids)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		example, err := ec2.GetNetworkInterfaces(ctx, nil, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("example", example.Ids)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var example = Aws.Ec2.GetNetworkInterfaces.Invoke();
    
        return new Dictionary<string, object?>
        {
            ["example"] = example.Apply(getNetworkInterfacesResult => getNetworkInterfacesResult.Ids),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.ec2.Ec2Functions;
    import com.pulumi.aws.ec2.inputs.GetNetworkInterfacesArgs;
    import java.util.List;
    import java.util.ArrayList;
    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) {
            final var example = Ec2Functions.getNetworkInterfaces();
    
            ctx.export("example", example.applyValue(getNetworkInterfacesResult -> getNetworkInterfacesResult.ids()));
        }
    }
    
    variables:
      example:
        fn::invoke:
          Function: aws:ec2:getNetworkInterfaces
          Arguments: {}
    outputs:
      example: ${example.ids}
    

    The following example retrieves a list of all network interface ids with a custom tag of Name set to a value of test.

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const example = aws.ec2.getNetworkInterfaces({
        tags: {
            Name: "test",
        },
    });
    export const example1 = example.then(example => example.ids);
    
    import pulumi
    import pulumi_aws as aws
    
    example = aws.ec2.get_network_interfaces(tags={
        "Name": "test",
    })
    pulumi.export("example1", example.ids)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		example, err := ec2.GetNetworkInterfaces(ctx, &ec2.GetNetworkInterfacesArgs{
    			Tags: map[string]interface{}{
    				"Name": "test",
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("example1", example.Ids)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var example = Aws.Ec2.GetNetworkInterfaces.Invoke(new()
        {
            Tags = 
            {
                { "Name", "test" },
            },
        });
    
        return new Dictionary<string, object?>
        {
            ["example1"] = example.Apply(getNetworkInterfacesResult => getNetworkInterfacesResult.Ids),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.ec2.Ec2Functions;
    import com.pulumi.aws.ec2.inputs.GetNetworkInterfacesArgs;
    import java.util.List;
    import java.util.ArrayList;
    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) {
            final var example = Ec2Functions.getNetworkInterfaces(GetNetworkInterfacesArgs.builder()
                .tags(Map.of("Name", "test"))
                .build());
    
            ctx.export("example1", example.applyValue(getNetworkInterfacesResult -> getNetworkInterfacesResult.ids()));
        }
    }
    
    variables:
      example:
        fn::invoke:
          Function: aws:ec2:getNetworkInterfaces
          Arguments:
            tags:
              Name: test
    outputs:
      example1: ${example.ids}
    

    The following example retrieves a network interface ids which associated with specific subnet.

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    export = async () => {
        const example = await aws.ec2.getNetworkInterfaces({
            filters: [{
                name: "subnet-id",
                values: [test.id],
            }],
        });
        return {
            example: example.ids,
        };
    }
    
    import pulumi
    import pulumi_aws as aws
    
    example = aws.ec2.get_network_interfaces(filters=[{
        "name": "subnet-id",
        "values": [test["id"]],
    }])
    pulumi.export("example", example.ids)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
    example, err := ec2.GetNetworkInterfaces(ctx, &ec2.GetNetworkInterfacesArgs{
    Filters: []ec2.GetNetworkInterfacesFilter{
    {
    Name: "subnet-id",
    Values: interface{}{
    test.Id,
    },
    },
    },
    }, nil);
    if err != nil {
    return err
    }
    ctx.Export("example", example.Ids)
    return nil
    })
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var example = Aws.Ec2.GetNetworkInterfaces.Invoke(new()
        {
            Filters = new[]
            {
                new Aws.Ec2.Inputs.GetNetworkInterfacesFilterInputArgs
                {
                    Name = "subnet-id",
                    Values = new[]
                    {
                        test.Id,
                    },
                },
            },
        });
    
        return new Dictionary<string, object?>
        {
            ["example"] = example.Apply(getNetworkInterfacesResult => getNetworkInterfacesResult.Ids),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.ec2.Ec2Functions;
    import com.pulumi.aws.ec2.inputs.GetNetworkInterfacesArgs;
    import java.util.List;
    import java.util.ArrayList;
    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) {
            final var example = Ec2Functions.getNetworkInterfaces(GetNetworkInterfacesArgs.builder()
                .filters(GetNetworkInterfacesFilterArgs.builder()
                    .name("subnet-id")
                    .values(test.id())
                    .build())
                .build());
    
            ctx.export("example", example.applyValue(getNetworkInterfacesResult -> getNetworkInterfacesResult.ids()));
        }
    }
    
    variables:
      example:
        fn::invoke:
          Function: aws:ec2:getNetworkInterfaces
          Arguments:
            filters:
              - name: subnet-id
                values:
                  - ${test.id}
    outputs:
      example: ${example.ids}
    

    Using getNetworkInterfaces

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getNetworkInterfaces(args: GetNetworkInterfacesArgs, opts?: InvokeOptions): Promise<GetNetworkInterfacesResult>
    function getNetworkInterfacesOutput(args: GetNetworkInterfacesOutputArgs, opts?: InvokeOptions): Output<GetNetworkInterfacesResult>
    def get_network_interfaces(filters: Optional[Sequence[GetNetworkInterfacesFilter]] = None,
                               tags: Optional[Mapping[str, str]] = None,
                               opts: Optional[InvokeOptions] = None) -> GetNetworkInterfacesResult
    def get_network_interfaces_output(filters: Optional[pulumi.Input[Sequence[pulumi.Input[GetNetworkInterfacesFilterArgs]]]] = None,
                               tags: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
                               opts: Optional[InvokeOptions] = None) -> Output[GetNetworkInterfacesResult]
    func GetNetworkInterfaces(ctx *Context, args *GetNetworkInterfacesArgs, opts ...InvokeOption) (*GetNetworkInterfacesResult, error)
    func GetNetworkInterfacesOutput(ctx *Context, args *GetNetworkInterfacesOutputArgs, opts ...InvokeOption) GetNetworkInterfacesResultOutput

    > Note: This function is named GetNetworkInterfaces in the Go SDK.

    public static class GetNetworkInterfaces 
    {
        public static Task<GetNetworkInterfacesResult> InvokeAsync(GetNetworkInterfacesArgs args, InvokeOptions? opts = null)
        public static Output<GetNetworkInterfacesResult> Invoke(GetNetworkInterfacesInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetNetworkInterfacesResult> getNetworkInterfaces(GetNetworkInterfacesArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: aws:ec2/getNetworkInterfaces:getNetworkInterfaces
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Filters List<GetNetworkInterfacesFilter>

    Custom filter block as described below.

    More complex filters can be expressed using one or more filter sub-blocks, which take the following arguments:

    Tags Dictionary<string, string>
    Map of tags, each pair of which must exactly match a pair on the desired network interfaces.
    Filters []GetNetworkInterfacesFilter

    Custom filter block as described below.

    More complex filters can be expressed using one or more filter sub-blocks, which take the following arguments:

    Tags map[string]string
    Map of tags, each pair of which must exactly match a pair on the desired network interfaces.
    filters List<GetNetworkInterfacesFilter>

    Custom filter block as described below.

    More complex filters can be expressed using one or more filter sub-blocks, which take the following arguments:

    tags Map<String,String>
    Map of tags, each pair of which must exactly match a pair on the desired network interfaces.
    filters GetNetworkInterfacesFilter[]

    Custom filter block as described below.

    More complex filters can be expressed using one or more filter sub-blocks, which take the following arguments:

    tags {[key: string]: string}
    Map of tags, each pair of which must exactly match a pair on the desired network interfaces.
    filters Sequence[GetNetworkInterfacesFilter]

    Custom filter block as described below.

    More complex filters can be expressed using one or more filter sub-blocks, which take the following arguments:

    tags Mapping[str, str]
    Map of tags, each pair of which must exactly match a pair on the desired network interfaces.
    filters List<Property Map>

    Custom filter block as described below.

    More complex filters can be expressed using one or more filter sub-blocks, which take the following arguments:

    tags Map<String>
    Map of tags, each pair of which must exactly match a pair on the desired network interfaces.

    getNetworkInterfaces Result

    The following output properties are available:

    Id string
    The provider-assigned unique ID for this managed resource.
    Ids List<string>
    List of all the network interface ids found.
    Tags Dictionary<string, string>
    Filters List<GetNetworkInterfacesFilter>
    Id string
    The provider-assigned unique ID for this managed resource.
    Ids []string
    List of all the network interface ids found.
    Tags map[string]string
    Filters []GetNetworkInterfacesFilter
    id String
    The provider-assigned unique ID for this managed resource.
    ids List<String>
    List of all the network interface ids found.
    tags Map<String,String>
    filters List<GetNetworkInterfacesFilter>
    id string
    The provider-assigned unique ID for this managed resource.
    ids string[]
    List of all the network interface ids found.
    tags {[key: string]: string}
    filters GetNetworkInterfacesFilter[]
    id str
    The provider-assigned unique ID for this managed resource.
    ids Sequence[str]
    List of all the network interface ids found.
    tags Mapping[str, str]
    filters Sequence[GetNetworkInterfacesFilter]
    id String
    The provider-assigned unique ID for this managed resource.
    ids List<String>
    List of all the network interface ids found.
    tags Map<String>
    filters List<Property Map>

    Supporting Types

    GetNetworkInterfacesFilter

    Name string
    Name of the field to filter by, as defined by the underlying AWS API.
    Values List<string>
    Set of values that are accepted for the given field.
    Name string
    Name of the field to filter by, as defined by the underlying AWS API.
    Values []string
    Set of values that are accepted for the given field.
    name String
    Name of the field to filter by, as defined by the underlying AWS API.
    values List<String>
    Set of values that are accepted for the given field.
    name string
    Name of the field to filter by, as defined by the underlying AWS API.
    values string[]
    Set of values that are accepted for the given field.
    name str
    Name of the field to filter by, as defined by the underlying AWS API.
    values Sequence[str]
    Set of values that are accepted for the given field.
    name String
    Name of the field to filter by, as defined by the underlying AWS API.
    values List<String>
    Set of values that are accepted for the given field.

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi