1. Packages
  2. AWS
  3. API Docs
  4. ec2
  5. getNetworkInterfaces
Viewing docs for AWS v5.43.0 (Older version)
published on Tuesday, Mar 10, 2026 by Pulumi
aws logo
Viewing docs for AWS v5.43.0 (Older version)
published on Tuesday, Mar 10, 2026 by Pulumi

    Example Usage

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

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

    .

    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 main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v5/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
    	})
    }
    
    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()));
        }
    }
    
    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)
    
    variables:
      example:
        fn::invoke:
          Function: aws:ec2:getNetworkInterfaces
          Arguments:
            tags:
              Name: test
    outputs:
      example1: ${example.ids}
    

    with specific subnet.

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var exampleNetworkInterfaces = Aws.Ec2.GetNetworkInterfaces.Invoke(new()
        {
            Filters = new[]
            {
                new Aws.Ec2.Inputs.GetNetworkInterfacesFilterInputArgs
                {
                    Name = "subnet-id",
                    Values = new[]
                    {
                        aws_subnet.Test.Id,
                    },
                },
            },
        });
    
        return new Dictionary<string, object?>
        {
            ["example"] = exampleNetworkInterfaces.Apply(getNetworkInterfacesResult => getNetworkInterfacesResult.Ids),
        };
    });
    
    package main
    
    import (
    
    "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ec2"
    )
    func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
    exampleNetworkInterfaces, err := ec2.GetNetworkInterfaces(ctx, &ec2.GetNetworkInterfacesArgs{
    Filters: []ec2.GetNetworkInterfacesFilter{
    {
    Name: "subnet-id",
    Values: interface{}{
    aws_subnet.Test.Id,
    },
    },
    },
    }, nil);
    if err != nil {
    return err
    }
    ctx.Export("example", exampleNetworkInterfaces.Ids)
    return nil
    })
    }
    
    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 exampleNetworkInterfaces = Ec2Functions.getNetworkInterfaces(GetNetworkInterfacesArgs.builder()
                .filters(GetNetworkInterfacesFilterArgs.builder()
                    .name("subnet-id")
                    .values(aws_subnet.test().id())
                    .build())
                .build());
    
            ctx.export("example", exampleNetworkInterfaces.applyValue(getNetworkInterfacesResult -> getNetworkInterfacesResult.ids()));
        }
    }
    
    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const exampleNetworkInterfaces = aws.ec2.getNetworkInterfaces({
        filters: [{
            name: "subnet-id",
            values: [aws_subnet.test.id],
        }],
    });
    export const example = exampleNetworkInterfaces.then(exampleNetworkInterfaces => exampleNetworkInterfaces.ids);
    
    import pulumi
    import pulumi_aws as aws
    
    example_network_interfaces = aws.ec2.get_network_interfaces(filters=[aws.ec2.GetNetworkInterfacesFilterArgs(
        name="subnet-id",
        values=[aws_subnet["test"]["id"]],
    )])
    pulumi.export("example", example_network_interfaces.ids)
    
    variables:
      exampleNetworkInterfaces:
        fn::invoke:
          Function: aws:ec2:getNetworkInterfaces
          Arguments:
            filters:
              - name: subnet-id
                values:
                  - ${aws_subnet.test.id}
    outputs:
      example: ${exampleNetworkInterfaces.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)
    public static Output<GetNetworkInterfacesResult> getNetworkInterfaces(GetNetworkInterfacesArgs args, InvokeOptions options)
    
    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
    Viewing docs for AWS v5.43.0 (Older version)
    published on Tuesday, Mar 10, 2026 by Pulumi
      Try Pulumi Cloud free. Your team will thank you.