GetVpcs

This resource can be useful for getting back a list of VPC Ids for a region.

The following example retrieves a list of VPC Ids with a custom tag of service set to a value of “production”.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var fooVpcs = Output.Create(Aws.Ec2.GetVpcs.InvokeAsync(new Aws.Ec2.GetVpcsArgs
        {
            Tags = 
            {
                { "service", "production" },
            },
        }));
        this.Foo = fooVpcs.Apply(fooVpcs => fooVpcs.Ids);
    }

    [Output("foo")]
    public Output<string> Foo { get; set; }
}
package main

import (
    "github.com/pulumi/pulumi-aws/sdk/v2/go/aws/ec2"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        fooVpcs, err := ec2.GetVpcs(ctx, &ec2.GetVpcsArgs{
            Tags: map[string]interface{}{
                "service": "production",
            },
        }, nil)
        if err != nil {
            return err
        }
        ctx.Export("foo", fooVpcs.Ids)
        return nil
    })
}
import pulumi
import pulumi_aws as aws

foo_vpcs = aws.ec2.get_vpcs(tags={
    "service": "production",
})
pulumi.export("foo", foo_vpcs.ids)
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const fooVpcs = pulumi.output(aws.ec2.getVpcs({
    tags: {
        service: "production",
    },
}, { async: true }));

export const foo = fooVpcs.ids;

Using GetVpcs

function getVpcs(args: GetVpcsArgs, opts?: InvokeOptions): Promise<GetVpcsResult>
function  get_vpcs(filters=None, tags=None, opts=None)
func GetVpcs(ctx *Context, args *GetVpcsArgs, opts ...InvokeOption) (*GetVpcsResult, error)
public static class GetVpcs {
    public static Task<GetVpcsResult> InvokeAsync(GetVpcsArgs args, InvokeOptions? opts = null)
}

The following arguments are supported:

Filters List<GetVpcsFilterArgs>

Custom filter block as described below.

Tags Dictionary<string, string>

A map of tags, each pair of which must exactly match a pair on the desired vpcs.

Filters []GetVpcsFilter

Custom filter block as described below.

Tags map[string]string

A map of tags, each pair of which must exactly match a pair on the desired vpcs.

filters GetVpcsFilter[]

Custom filter block as described below.

tags {[key: string]: string}

A map of tags, each pair of which must exactly match a pair on the desired vpcs.

filters List[GetVpcsFilter]

Custom filter block as described below.

tags Dict[str, str]

A map of tags, each pair of which must exactly match a pair on the desired vpcs.

GetVpcs Result

The following output properties are available:

Id string

The provider-assigned unique ID for this managed resource.

Ids List<string>

A list of all the VPC Ids found. This data source will fail if none are found.

Tags Dictionary<string, string>
Filters List<GetVpcsFilter>
Id string

The provider-assigned unique ID for this managed resource.

Ids []string

A list of all the VPC Ids found. This data source will fail if none are found.

Tags map[string]string
Filters []GetVpcsFilter
id string

The provider-assigned unique ID for this managed resource.

ids string[]

A list of all the VPC Ids found. This data source will fail if none are found.

tags {[key: string]: string}
filters GetVpcsFilter[]
id str

The provider-assigned unique ID for this managed resource.

ids List[str]

A list of all the VPC Ids found. This data source will fail if none are found.

tags Dict[str, str]
filters List[GetVpcsFilter]

Supporting Types

GetVpcsFilter

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

Name string

The 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. A VPC will be selected if any one of the given values matches.

Name string

The 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. A VPC will be selected if any one of the given values matches.

name string

The 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. A VPC will be selected if any one of the given values matches.

name str

The name of the field to filter by, as defined by the underlying AWS API.

values List[str]

Set of values that are accepted for the given field. A VPC will be selected if any one of the given values matches.

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.