github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/ec2/getVpc.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  // `ec2.Vpc` provides details about a specific VPC.
    15  //
    16  // This resource can prove useful when a module accepts a vpc id as
    17  // an input variable and needs to, for example, determine the CIDR block of that
    18  // VPC.
    19  //
    20  // ## Example Usage
    21  //
    22  // The following example shows how one might accept a VPC id as a variable
    23  // and use this data source to obtain the data necessary to create a subnet
    24  // within it.
    25  //
    26  // <!--Start PulumiCodeChooser -->
    27  // ```go
    28  // package main
    29  //
    30  // import (
    31  //
    32  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
    33  //	"github.com/pulumi/pulumi-std/sdk/go/std"
    34  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    35  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
    36  //
    37  // )
    38  //
    39  //	func main() {
    40  //		pulumi.Run(func(ctx *pulumi.Context) error {
    41  //			cfg := config.New(ctx, "")
    42  //			vpcId := cfg.RequireObject("vpcId")
    43  //			selected, err := ec2.LookupVpc(ctx, &ec2.LookupVpcArgs{
    44  //				Id: pulumi.StringRef(vpcId),
    45  //			}, nil)
    46  //			if err != nil {
    47  //				return err
    48  //			}
    49  //			invokeCidrsubnet, err := std.Cidrsubnet(ctx, &std.CidrsubnetArgs{
    50  //				Input:   selected.CidrBlock,
    51  //				Newbits: 4,
    52  //				Netnum:  1,
    53  //			}, nil)
    54  //			if err != nil {
    55  //				return err
    56  //			}
    57  //			_, err = ec2.NewSubnet(ctx, "example", &ec2.SubnetArgs{
    58  //				VpcId:            pulumi.String(selected.Id),
    59  //				AvailabilityZone: pulumi.String("us-west-2a"),
    60  //				CidrBlock:        invokeCidrsubnet.Result,
    61  //			})
    62  //			if err != nil {
    63  //				return err
    64  //			}
    65  //			return nil
    66  //		})
    67  //	}
    68  //
    69  // ```
    70  // <!--End PulumiCodeChooser -->
    71  func LookupVpc(ctx *pulumi.Context, args *LookupVpcArgs, opts ...pulumi.InvokeOption) (*LookupVpcResult, error) {
    72  	opts = internal.PkgInvokeDefaultOpts(opts)
    73  	var rv LookupVpcResult
    74  	err := ctx.Invoke("aws:ec2/getVpc:getVpc", args, &rv, opts...)
    75  	if err != nil {
    76  		return nil, err
    77  	}
    78  	return &rv, nil
    79  }
    80  
    81  // A collection of arguments for invoking getVpc.
    82  type LookupVpcArgs struct {
    83  	// Cidr block of the desired VPC.
    84  	CidrBlock *string `pulumi:"cidrBlock"`
    85  	// Boolean constraint on whether the desired VPC is
    86  	// the default VPC for the region.
    87  	Default *bool `pulumi:"default"`
    88  	// DHCP options id of the desired VPC.
    89  	DhcpOptionsId *string `pulumi:"dhcpOptionsId"`
    90  	// Custom filter block as described below.
    91  	Filters []GetVpcFilter `pulumi:"filters"`
    92  	// ID of the specific VPC to retrieve.
    93  	Id *string `pulumi:"id"`
    94  	// Current state of the desired VPC.
    95  	// Can be either `"pending"` or `"available"`.
    96  	State *string `pulumi:"state"`
    97  	// Map of tags, each pair of which must exactly match
    98  	// a pair on the desired VPC.
    99  	//
   100  	// More complex filters can be expressed using one or more `filter` sub-blocks,
   101  	// which take the following arguments:
   102  	Tags map[string]string `pulumi:"tags"`
   103  }
   104  
   105  // A collection of values returned by getVpc.
   106  type LookupVpcResult struct {
   107  	// ARN of VPC
   108  	Arn string `pulumi:"arn"`
   109  	// CIDR block for the association.
   110  	CidrBlock             string                       `pulumi:"cidrBlock"`
   111  	CidrBlockAssociations []GetVpcCidrBlockAssociation `pulumi:"cidrBlockAssociations"`
   112  	Default               bool                         `pulumi:"default"`
   113  	DhcpOptionsId         string                       `pulumi:"dhcpOptionsId"`
   114  	// Whether or not the VPC has DNS hostname support
   115  	EnableDnsHostnames bool `pulumi:"enableDnsHostnames"`
   116  	// Whether or not the VPC has DNS support
   117  	EnableDnsSupport bool `pulumi:"enableDnsSupport"`
   118  	// Whether Network Address Usage metrics are enabled for your VPC
   119  	EnableNetworkAddressUsageMetrics bool           `pulumi:"enableNetworkAddressUsageMetrics"`
   120  	Filters                          []GetVpcFilter `pulumi:"filters"`
   121  	Id                               string         `pulumi:"id"`
   122  	// Allowed tenancy of instances launched into the
   123  	// selected VPC. May be any of `"default"`, `"dedicated"`, or `"host"`.
   124  	InstanceTenancy string `pulumi:"instanceTenancy"`
   125  	// Association ID for the IPv6 CIDR block.
   126  	Ipv6AssociationId string `pulumi:"ipv6AssociationId"`
   127  	// IPv6 CIDR block.
   128  	Ipv6CidrBlock string `pulumi:"ipv6CidrBlock"`
   129  	// ID of the main route table associated with this VPC.
   130  	MainRouteTableId string `pulumi:"mainRouteTableId"`
   131  	// ID of the AWS account that owns the VPC.
   132  	OwnerId string `pulumi:"ownerId"`
   133  	// State of the association.
   134  	State string            `pulumi:"state"`
   135  	Tags  map[string]string `pulumi:"tags"`
   136  }
   137  
   138  func LookupVpcOutput(ctx *pulumi.Context, args LookupVpcOutputArgs, opts ...pulumi.InvokeOption) LookupVpcResultOutput {
   139  	return pulumi.ToOutputWithContext(context.Background(), args).
   140  		ApplyT(func(v interface{}) (LookupVpcResult, error) {
   141  			args := v.(LookupVpcArgs)
   142  			r, err := LookupVpc(ctx, &args, opts...)
   143  			var s LookupVpcResult
   144  			if r != nil {
   145  				s = *r
   146  			}
   147  			return s, err
   148  		}).(LookupVpcResultOutput)
   149  }
   150  
   151  // A collection of arguments for invoking getVpc.
   152  type LookupVpcOutputArgs struct {
   153  	// Cidr block of the desired VPC.
   154  	CidrBlock pulumi.StringPtrInput `pulumi:"cidrBlock"`
   155  	// Boolean constraint on whether the desired VPC is
   156  	// the default VPC for the region.
   157  	Default pulumi.BoolPtrInput `pulumi:"default"`
   158  	// DHCP options id of the desired VPC.
   159  	DhcpOptionsId pulumi.StringPtrInput `pulumi:"dhcpOptionsId"`
   160  	// Custom filter block as described below.
   161  	Filters GetVpcFilterArrayInput `pulumi:"filters"`
   162  	// ID of the specific VPC to retrieve.
   163  	Id pulumi.StringPtrInput `pulumi:"id"`
   164  	// Current state of the desired VPC.
   165  	// Can be either `"pending"` or `"available"`.
   166  	State pulumi.StringPtrInput `pulumi:"state"`
   167  	// Map of tags, each pair of which must exactly match
   168  	// a pair on the desired VPC.
   169  	//
   170  	// More complex filters can be expressed using one or more `filter` sub-blocks,
   171  	// which take the following arguments:
   172  	Tags pulumi.StringMapInput `pulumi:"tags"`
   173  }
   174  
   175  func (LookupVpcOutputArgs) ElementType() reflect.Type {
   176  	return reflect.TypeOf((*LookupVpcArgs)(nil)).Elem()
   177  }
   178  
   179  // A collection of values returned by getVpc.
   180  type LookupVpcResultOutput struct{ *pulumi.OutputState }
   181  
   182  func (LookupVpcResultOutput) ElementType() reflect.Type {
   183  	return reflect.TypeOf((*LookupVpcResult)(nil)).Elem()
   184  }
   185  
   186  func (o LookupVpcResultOutput) ToLookupVpcResultOutput() LookupVpcResultOutput {
   187  	return o
   188  }
   189  
   190  func (o LookupVpcResultOutput) ToLookupVpcResultOutputWithContext(ctx context.Context) LookupVpcResultOutput {
   191  	return o
   192  }
   193  
   194  // ARN of VPC
   195  func (o LookupVpcResultOutput) Arn() pulumi.StringOutput {
   196  	return o.ApplyT(func(v LookupVpcResult) string { return v.Arn }).(pulumi.StringOutput)
   197  }
   198  
   199  // CIDR block for the association.
   200  func (o LookupVpcResultOutput) CidrBlock() pulumi.StringOutput {
   201  	return o.ApplyT(func(v LookupVpcResult) string { return v.CidrBlock }).(pulumi.StringOutput)
   202  }
   203  
   204  func (o LookupVpcResultOutput) CidrBlockAssociations() GetVpcCidrBlockAssociationArrayOutput {
   205  	return o.ApplyT(func(v LookupVpcResult) []GetVpcCidrBlockAssociation { return v.CidrBlockAssociations }).(GetVpcCidrBlockAssociationArrayOutput)
   206  }
   207  
   208  func (o LookupVpcResultOutput) Default() pulumi.BoolOutput {
   209  	return o.ApplyT(func(v LookupVpcResult) bool { return v.Default }).(pulumi.BoolOutput)
   210  }
   211  
   212  func (o LookupVpcResultOutput) DhcpOptionsId() pulumi.StringOutput {
   213  	return o.ApplyT(func(v LookupVpcResult) string { return v.DhcpOptionsId }).(pulumi.StringOutput)
   214  }
   215  
   216  // Whether or not the VPC has DNS hostname support
   217  func (o LookupVpcResultOutput) EnableDnsHostnames() pulumi.BoolOutput {
   218  	return o.ApplyT(func(v LookupVpcResult) bool { return v.EnableDnsHostnames }).(pulumi.BoolOutput)
   219  }
   220  
   221  // Whether or not the VPC has DNS support
   222  func (o LookupVpcResultOutput) EnableDnsSupport() pulumi.BoolOutput {
   223  	return o.ApplyT(func(v LookupVpcResult) bool { return v.EnableDnsSupport }).(pulumi.BoolOutput)
   224  }
   225  
   226  // Whether Network Address Usage metrics are enabled for your VPC
   227  func (o LookupVpcResultOutput) EnableNetworkAddressUsageMetrics() pulumi.BoolOutput {
   228  	return o.ApplyT(func(v LookupVpcResult) bool { return v.EnableNetworkAddressUsageMetrics }).(pulumi.BoolOutput)
   229  }
   230  
   231  func (o LookupVpcResultOutput) Filters() GetVpcFilterArrayOutput {
   232  	return o.ApplyT(func(v LookupVpcResult) []GetVpcFilter { return v.Filters }).(GetVpcFilterArrayOutput)
   233  }
   234  
   235  func (o LookupVpcResultOutput) Id() pulumi.StringOutput {
   236  	return o.ApplyT(func(v LookupVpcResult) string { return v.Id }).(pulumi.StringOutput)
   237  }
   238  
   239  // Allowed tenancy of instances launched into the
   240  // selected VPC. May be any of `"default"`, `"dedicated"`, or `"host"`.
   241  func (o LookupVpcResultOutput) InstanceTenancy() pulumi.StringOutput {
   242  	return o.ApplyT(func(v LookupVpcResult) string { return v.InstanceTenancy }).(pulumi.StringOutput)
   243  }
   244  
   245  // Association ID for the IPv6 CIDR block.
   246  func (o LookupVpcResultOutput) Ipv6AssociationId() pulumi.StringOutput {
   247  	return o.ApplyT(func(v LookupVpcResult) string { return v.Ipv6AssociationId }).(pulumi.StringOutput)
   248  }
   249  
   250  // IPv6 CIDR block.
   251  func (o LookupVpcResultOutput) Ipv6CidrBlock() pulumi.StringOutput {
   252  	return o.ApplyT(func(v LookupVpcResult) string { return v.Ipv6CidrBlock }).(pulumi.StringOutput)
   253  }
   254  
   255  // ID of the main route table associated with this VPC.
   256  func (o LookupVpcResultOutput) MainRouteTableId() pulumi.StringOutput {
   257  	return o.ApplyT(func(v LookupVpcResult) string { return v.MainRouteTableId }).(pulumi.StringOutput)
   258  }
   259  
   260  // ID of the AWS account that owns the VPC.
   261  func (o LookupVpcResultOutput) OwnerId() pulumi.StringOutput {
   262  	return o.ApplyT(func(v LookupVpcResult) string { return v.OwnerId }).(pulumi.StringOutput)
   263  }
   264  
   265  // State of the association.
   266  func (o LookupVpcResultOutput) State() pulumi.StringOutput {
   267  	return o.ApplyT(func(v LookupVpcResult) string { return v.State }).(pulumi.StringOutput)
   268  }
   269  
   270  func (o LookupVpcResultOutput) Tags() pulumi.StringMapOutput {
   271  	return o.ApplyT(func(v LookupVpcResult) map[string]string { return v.Tags }).(pulumi.StringMapOutput)
   272  }
   273  
   274  func init() {
   275  	pulumi.RegisterOutputType(LookupVpcResultOutput{})
   276  }