github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/ec2/getRoute.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.Route` provides details about a specific Route.
    15  //
    16  // This resource can prove useful when finding the resource associated with a CIDR. For example, finding the peering connection associated with a CIDR value.
    17  //
    18  // ## Example Usage
    19  //
    20  // The following example shows how one might use a CIDR value to find a network interface id and use this to create a data source of that network interface.
    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  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
    31  //
    32  // )
    33  //
    34  //	func main() {
    35  //		pulumi.Run(func(ctx *pulumi.Context) error {
    36  //			cfg := config.New(ctx, "")
    37  //			subnetId := cfg.RequireObject("subnetId")
    38  //			_, err := ec2.LookupRouteTable(ctx, &ec2.LookupRouteTableArgs{
    39  //				SubnetId: pulumi.StringRef(subnetId),
    40  //			}, nil)
    41  //			if err != nil {
    42  //				return err
    43  //			}
    44  //			route, err := ec2.LookupRoute(ctx, &ec2.LookupRouteArgs{
    45  //				RouteTableId:         selectedAwsRouteTable.Id,
    46  //				DestinationCidrBlock: pulumi.StringRef("10.0.1.0/24"),
    47  //			}, nil)
    48  //			if err != nil {
    49  //				return err
    50  //			}
    51  //			_, err = ec2.LookupNetworkInterface(ctx, &ec2.LookupNetworkInterfaceArgs{
    52  //				Id: pulumi.StringRef(route.NetworkInterfaceId),
    53  //			}, nil)
    54  //			if err != nil {
    55  //				return err
    56  //			}
    57  //			return nil
    58  //		})
    59  //	}
    60  //
    61  // ```
    62  // <!--End PulumiCodeChooser -->
    63  func LookupRoute(ctx *pulumi.Context, args *LookupRouteArgs, opts ...pulumi.InvokeOption) (*LookupRouteResult, error) {
    64  	opts = internal.PkgInvokeDefaultOpts(opts)
    65  	var rv LookupRouteResult
    66  	err := ctx.Invoke("aws:ec2/getRoute:getRoute", args, &rv, opts...)
    67  	if err != nil {
    68  		return nil, err
    69  	}
    70  	return &rv, nil
    71  }
    72  
    73  // A collection of arguments for invoking getRoute.
    74  type LookupRouteArgs struct {
    75  	// EC2 Carrier Gateway ID of the Route belonging to the Route Table.
    76  	CarrierGatewayId *string `pulumi:"carrierGatewayId"`
    77  	// Core network ARN of the Route belonging to the Route Table.
    78  	CoreNetworkArn *string `pulumi:"coreNetworkArn"`
    79  	// CIDR block of the Route belonging to the Route Table.
    80  	DestinationCidrBlock *string `pulumi:"destinationCidrBlock"`
    81  	// IPv6 CIDR block of the Route belonging to the Route Table.
    82  	DestinationIpv6CidrBlock *string `pulumi:"destinationIpv6CidrBlock"`
    83  	// ID of a managed prefix list destination of the Route belonging to the Route Table.
    84  	DestinationPrefixListId *string `pulumi:"destinationPrefixListId"`
    85  	// Egress Only Gateway ID of the Route belonging to the Route Table.
    86  	EgressOnlyGatewayId *string `pulumi:"egressOnlyGatewayId"`
    87  	// Gateway ID of the Route belonging to the Route Table.
    88  	GatewayId *string `pulumi:"gatewayId"`
    89  	// Instance ID of the Route belonging to the Route Table.
    90  	InstanceId *string `pulumi:"instanceId"`
    91  	// Local Gateway ID of the Route belonging to the Route Table.
    92  	LocalGatewayId *string `pulumi:"localGatewayId"`
    93  	// NAT Gateway ID of the Route belonging to the Route Table.
    94  	NatGatewayId *string `pulumi:"natGatewayId"`
    95  	// Network Interface ID of the Route belonging to the Route Table.
    96  	NetworkInterfaceId *string `pulumi:"networkInterfaceId"`
    97  	// ID of the specific Route Table containing the Route entry.
    98  	//
    99  	// The following arguments are optional:
   100  	RouteTableId string `pulumi:"routeTableId"`
   101  	// EC2 Transit Gateway ID of the Route belonging to the Route Table.
   102  	TransitGatewayId *string `pulumi:"transitGatewayId"`
   103  	// VPC Peering Connection ID of the Route belonging to the Route Table.
   104  	VpcPeeringConnectionId *string `pulumi:"vpcPeeringConnectionId"`
   105  }
   106  
   107  // A collection of values returned by getRoute.
   108  type LookupRouteResult struct {
   109  	CarrierGatewayId         string `pulumi:"carrierGatewayId"`
   110  	CoreNetworkArn           string `pulumi:"coreNetworkArn"`
   111  	DestinationCidrBlock     string `pulumi:"destinationCidrBlock"`
   112  	DestinationIpv6CidrBlock string `pulumi:"destinationIpv6CidrBlock"`
   113  	DestinationPrefixListId  string `pulumi:"destinationPrefixListId"`
   114  	EgressOnlyGatewayId      string `pulumi:"egressOnlyGatewayId"`
   115  	GatewayId                string `pulumi:"gatewayId"`
   116  	// The provider-assigned unique ID for this managed resource.
   117  	Id                     string `pulumi:"id"`
   118  	InstanceId             string `pulumi:"instanceId"`
   119  	LocalGatewayId         string `pulumi:"localGatewayId"`
   120  	NatGatewayId           string `pulumi:"natGatewayId"`
   121  	NetworkInterfaceId     string `pulumi:"networkInterfaceId"`
   122  	RouteTableId           string `pulumi:"routeTableId"`
   123  	TransitGatewayId       string `pulumi:"transitGatewayId"`
   124  	VpcPeeringConnectionId string `pulumi:"vpcPeeringConnectionId"`
   125  }
   126  
   127  func LookupRouteOutput(ctx *pulumi.Context, args LookupRouteOutputArgs, opts ...pulumi.InvokeOption) LookupRouteResultOutput {
   128  	return pulumi.ToOutputWithContext(context.Background(), args).
   129  		ApplyT(func(v interface{}) (LookupRouteResult, error) {
   130  			args := v.(LookupRouteArgs)
   131  			r, err := LookupRoute(ctx, &args, opts...)
   132  			var s LookupRouteResult
   133  			if r != nil {
   134  				s = *r
   135  			}
   136  			return s, err
   137  		}).(LookupRouteResultOutput)
   138  }
   139  
   140  // A collection of arguments for invoking getRoute.
   141  type LookupRouteOutputArgs struct {
   142  	// EC2 Carrier Gateway ID of the Route belonging to the Route Table.
   143  	CarrierGatewayId pulumi.StringPtrInput `pulumi:"carrierGatewayId"`
   144  	// Core network ARN of the Route belonging to the Route Table.
   145  	CoreNetworkArn pulumi.StringPtrInput `pulumi:"coreNetworkArn"`
   146  	// CIDR block of the Route belonging to the Route Table.
   147  	DestinationCidrBlock pulumi.StringPtrInput `pulumi:"destinationCidrBlock"`
   148  	// IPv6 CIDR block of the Route belonging to the Route Table.
   149  	DestinationIpv6CidrBlock pulumi.StringPtrInput `pulumi:"destinationIpv6CidrBlock"`
   150  	// ID of a managed prefix list destination of the Route belonging to the Route Table.
   151  	DestinationPrefixListId pulumi.StringPtrInput `pulumi:"destinationPrefixListId"`
   152  	// Egress Only Gateway ID of the Route belonging to the Route Table.
   153  	EgressOnlyGatewayId pulumi.StringPtrInput `pulumi:"egressOnlyGatewayId"`
   154  	// Gateway ID of the Route belonging to the Route Table.
   155  	GatewayId pulumi.StringPtrInput `pulumi:"gatewayId"`
   156  	// Instance ID of the Route belonging to the Route Table.
   157  	InstanceId pulumi.StringPtrInput `pulumi:"instanceId"`
   158  	// Local Gateway ID of the Route belonging to the Route Table.
   159  	LocalGatewayId pulumi.StringPtrInput `pulumi:"localGatewayId"`
   160  	// NAT Gateway ID of the Route belonging to the Route Table.
   161  	NatGatewayId pulumi.StringPtrInput `pulumi:"natGatewayId"`
   162  	// Network Interface ID of the Route belonging to the Route Table.
   163  	NetworkInterfaceId pulumi.StringPtrInput `pulumi:"networkInterfaceId"`
   164  	// ID of the specific Route Table containing the Route entry.
   165  	//
   166  	// The following arguments are optional:
   167  	RouteTableId pulumi.StringInput `pulumi:"routeTableId"`
   168  	// EC2 Transit Gateway ID of the Route belonging to the Route Table.
   169  	TransitGatewayId pulumi.StringPtrInput `pulumi:"transitGatewayId"`
   170  	// VPC Peering Connection ID of the Route belonging to the Route Table.
   171  	VpcPeeringConnectionId pulumi.StringPtrInput `pulumi:"vpcPeeringConnectionId"`
   172  }
   173  
   174  func (LookupRouteOutputArgs) ElementType() reflect.Type {
   175  	return reflect.TypeOf((*LookupRouteArgs)(nil)).Elem()
   176  }
   177  
   178  // A collection of values returned by getRoute.
   179  type LookupRouteResultOutput struct{ *pulumi.OutputState }
   180  
   181  func (LookupRouteResultOutput) ElementType() reflect.Type {
   182  	return reflect.TypeOf((*LookupRouteResult)(nil)).Elem()
   183  }
   184  
   185  func (o LookupRouteResultOutput) ToLookupRouteResultOutput() LookupRouteResultOutput {
   186  	return o
   187  }
   188  
   189  func (o LookupRouteResultOutput) ToLookupRouteResultOutputWithContext(ctx context.Context) LookupRouteResultOutput {
   190  	return o
   191  }
   192  
   193  func (o LookupRouteResultOutput) CarrierGatewayId() pulumi.StringOutput {
   194  	return o.ApplyT(func(v LookupRouteResult) string { return v.CarrierGatewayId }).(pulumi.StringOutput)
   195  }
   196  
   197  func (o LookupRouteResultOutput) CoreNetworkArn() pulumi.StringOutput {
   198  	return o.ApplyT(func(v LookupRouteResult) string { return v.CoreNetworkArn }).(pulumi.StringOutput)
   199  }
   200  
   201  func (o LookupRouteResultOutput) DestinationCidrBlock() pulumi.StringOutput {
   202  	return o.ApplyT(func(v LookupRouteResult) string { return v.DestinationCidrBlock }).(pulumi.StringOutput)
   203  }
   204  
   205  func (o LookupRouteResultOutput) DestinationIpv6CidrBlock() pulumi.StringOutput {
   206  	return o.ApplyT(func(v LookupRouteResult) string { return v.DestinationIpv6CidrBlock }).(pulumi.StringOutput)
   207  }
   208  
   209  func (o LookupRouteResultOutput) DestinationPrefixListId() pulumi.StringOutput {
   210  	return o.ApplyT(func(v LookupRouteResult) string { return v.DestinationPrefixListId }).(pulumi.StringOutput)
   211  }
   212  
   213  func (o LookupRouteResultOutput) EgressOnlyGatewayId() pulumi.StringOutput {
   214  	return o.ApplyT(func(v LookupRouteResult) string { return v.EgressOnlyGatewayId }).(pulumi.StringOutput)
   215  }
   216  
   217  func (o LookupRouteResultOutput) GatewayId() pulumi.StringOutput {
   218  	return o.ApplyT(func(v LookupRouteResult) string { return v.GatewayId }).(pulumi.StringOutput)
   219  }
   220  
   221  // The provider-assigned unique ID for this managed resource.
   222  func (o LookupRouteResultOutput) Id() pulumi.StringOutput {
   223  	return o.ApplyT(func(v LookupRouteResult) string { return v.Id }).(pulumi.StringOutput)
   224  }
   225  
   226  func (o LookupRouteResultOutput) InstanceId() pulumi.StringOutput {
   227  	return o.ApplyT(func(v LookupRouteResult) string { return v.InstanceId }).(pulumi.StringOutput)
   228  }
   229  
   230  func (o LookupRouteResultOutput) LocalGatewayId() pulumi.StringOutput {
   231  	return o.ApplyT(func(v LookupRouteResult) string { return v.LocalGatewayId }).(pulumi.StringOutput)
   232  }
   233  
   234  func (o LookupRouteResultOutput) NatGatewayId() pulumi.StringOutput {
   235  	return o.ApplyT(func(v LookupRouteResult) string { return v.NatGatewayId }).(pulumi.StringOutput)
   236  }
   237  
   238  func (o LookupRouteResultOutput) NetworkInterfaceId() pulumi.StringOutput {
   239  	return o.ApplyT(func(v LookupRouteResult) string { return v.NetworkInterfaceId }).(pulumi.StringOutput)
   240  }
   241  
   242  func (o LookupRouteResultOutput) RouteTableId() pulumi.StringOutput {
   243  	return o.ApplyT(func(v LookupRouteResult) string { return v.RouteTableId }).(pulumi.StringOutput)
   244  }
   245  
   246  func (o LookupRouteResultOutput) TransitGatewayId() pulumi.StringOutput {
   247  	return o.ApplyT(func(v LookupRouteResult) string { return v.TransitGatewayId }).(pulumi.StringOutput)
   248  }
   249  
   250  func (o LookupRouteResultOutput) VpcPeeringConnectionId() pulumi.StringOutput {
   251  	return o.ApplyT(func(v LookupRouteResult) string { return v.VpcPeeringConnectionId }).(pulumi.StringOutput)
   252  }
   253  
   254  func init() {
   255  	pulumi.RegisterOutputType(LookupRouteResultOutput{})
   256  }