github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/ec2/getVpcs.go (about)

     1  // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
     2  // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
     3  
     4  package ec2
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    11  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    12  )
    13  
    14  // This resource can be useful for getting back a list of VPC Ids for a region.
    15  //
    16  // The following example retrieves a list of VPC Ids with a custom tag of `service` set to a value of "production".
    17  //
    18  // ## Example Usage
    19  //
    20  // The following shows outputting all VPC Ids.
    21  //
    22  // <!--Start PulumiCodeChooser -->
    23  // ```go
    24  // package main
    25  //
    26  // import (
    27  //
    28  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
    29  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    30  //
    31  // )
    32  //
    33  //	func main() {
    34  //		pulumi.Run(func(ctx *pulumi.Context) error {
    35  //			foo, err := ec2.GetVpcs(ctx, &ec2.GetVpcsArgs{
    36  //				Tags: map[string]interface{}{
    37  //					"service": "production",
    38  //				},
    39  //			}, nil)
    40  //			if err != nil {
    41  //				return err
    42  //			}
    43  //			ctx.Export("foo", foo.Ids)
    44  //			return nil
    45  //		})
    46  //	}
    47  //
    48  // ```
    49  // <!--End PulumiCodeChooser -->
    50  //
    51  // An example use case would be interpolate the `ec2.getVpcs` output into `count` of an ec2.FlowLog resource.
    52  func GetVpcs(ctx *pulumi.Context, args *GetVpcsArgs, opts ...pulumi.InvokeOption) (*GetVpcsResult, error) {
    53  	opts = internal.PkgInvokeDefaultOpts(opts)
    54  	var rv GetVpcsResult
    55  	err := ctx.Invoke("aws:ec2/getVpcs:getVpcs", args, &rv, opts...)
    56  	if err != nil {
    57  		return nil, err
    58  	}
    59  	return &rv, nil
    60  }
    61  
    62  // A collection of arguments for invoking getVpcs.
    63  type GetVpcsArgs struct {
    64  	// Custom filter block as described below.
    65  	//
    66  	// More complex filters can be expressed using one or more `filter` sub-blocks,
    67  	// which take the following arguments:
    68  	Filters []GetVpcsFilter `pulumi:"filters"`
    69  	// Map of tags, each pair of which must exactly match
    70  	// a pair on the desired vpcs.
    71  	Tags map[string]string `pulumi:"tags"`
    72  }
    73  
    74  // A collection of values returned by getVpcs.
    75  type GetVpcsResult struct {
    76  	Filters []GetVpcsFilter `pulumi:"filters"`
    77  	// The provider-assigned unique ID for this managed resource.
    78  	Id string `pulumi:"id"`
    79  	// List of all the VPC Ids found.
    80  	Ids  []string          `pulumi:"ids"`
    81  	Tags map[string]string `pulumi:"tags"`
    82  }
    83  
    84  func GetVpcsOutput(ctx *pulumi.Context, args GetVpcsOutputArgs, opts ...pulumi.InvokeOption) GetVpcsResultOutput {
    85  	return pulumi.ToOutputWithContext(context.Background(), args).
    86  		ApplyT(func(v interface{}) (GetVpcsResult, error) {
    87  			args := v.(GetVpcsArgs)
    88  			r, err := GetVpcs(ctx, &args, opts...)
    89  			var s GetVpcsResult
    90  			if r != nil {
    91  				s = *r
    92  			}
    93  			return s, err
    94  		}).(GetVpcsResultOutput)
    95  }
    96  
    97  // A collection of arguments for invoking getVpcs.
    98  type GetVpcsOutputArgs struct {
    99  	// Custom filter block as described below.
   100  	//
   101  	// More complex filters can be expressed using one or more `filter` sub-blocks,
   102  	// which take the following arguments:
   103  	Filters GetVpcsFilterArrayInput `pulumi:"filters"`
   104  	// Map of tags, each pair of which must exactly match
   105  	// a pair on the desired vpcs.
   106  	Tags pulumi.StringMapInput `pulumi:"tags"`
   107  }
   108  
   109  func (GetVpcsOutputArgs) ElementType() reflect.Type {
   110  	return reflect.TypeOf((*GetVpcsArgs)(nil)).Elem()
   111  }
   112  
   113  // A collection of values returned by getVpcs.
   114  type GetVpcsResultOutput struct{ *pulumi.OutputState }
   115  
   116  func (GetVpcsResultOutput) ElementType() reflect.Type {
   117  	return reflect.TypeOf((*GetVpcsResult)(nil)).Elem()
   118  }
   119  
   120  func (o GetVpcsResultOutput) ToGetVpcsResultOutput() GetVpcsResultOutput {
   121  	return o
   122  }
   123  
   124  func (o GetVpcsResultOutput) ToGetVpcsResultOutputWithContext(ctx context.Context) GetVpcsResultOutput {
   125  	return o
   126  }
   127  
   128  func (o GetVpcsResultOutput) Filters() GetVpcsFilterArrayOutput {
   129  	return o.ApplyT(func(v GetVpcsResult) []GetVpcsFilter { return v.Filters }).(GetVpcsFilterArrayOutput)
   130  }
   131  
   132  // The provider-assigned unique ID for this managed resource.
   133  func (o GetVpcsResultOutput) Id() pulumi.StringOutput {
   134  	return o.ApplyT(func(v GetVpcsResult) string { return v.Id }).(pulumi.StringOutput)
   135  }
   136  
   137  // List of all the VPC Ids found.
   138  func (o GetVpcsResultOutput) Ids() pulumi.StringArrayOutput {
   139  	return o.ApplyT(func(v GetVpcsResult) []string { return v.Ids }).(pulumi.StringArrayOutput)
   140  }
   141  
   142  func (o GetVpcsResultOutput) Tags() pulumi.StringMapOutput {
   143  	return o.ApplyT(func(v GetVpcsResult) map[string]string { return v.Tags }).(pulumi.StringMapOutput)
   144  }
   145  
   146  func init() {
   147  	pulumi.RegisterOutputType(GetVpcsResultOutput{})
   148  }