github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/ec2/getRouteTable.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.RouteTable` provides details about a specific Route Table. 15 // 16 // This resource can prove useful when a module accepts a Subnet ID as an input variable and needs to, for example, add a route in the Route Table. 17 // 18 // ## Example Usage 19 // 20 // The following example shows how one might accept a Route Table ID as a variable and use this data source to obtain the data necessary to create a route. 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 // selected, err := ec2.LookupRouteTable(ctx, &ec2.LookupRouteTableArgs{ 39 // SubnetId: pulumi.StringRef(subnetId), 40 // }, nil) 41 // if err != nil { 42 // return err 43 // } 44 // _, err = ec2.NewRoute(ctx, "route", &ec2.RouteArgs{ 45 // RouteTableId: pulumi.String(selected.Id), 46 // DestinationCidrBlock: pulumi.String("10.0.1.0/22"), 47 // VpcPeeringConnectionId: pulumi.String("pcx-45ff3dc1"), 48 // }) 49 // if err != nil { 50 // return err 51 // } 52 // return nil 53 // }) 54 // } 55 // 56 // ``` 57 // <!--End PulumiCodeChooser --> 58 func LookupRouteTable(ctx *pulumi.Context, args *LookupRouteTableArgs, opts ...pulumi.InvokeOption) (*LookupRouteTableResult, error) { 59 opts = internal.PkgInvokeDefaultOpts(opts) 60 var rv LookupRouteTableResult 61 err := ctx.Invoke("aws:ec2/getRouteTable:getRouteTable", args, &rv, opts...) 62 if err != nil { 63 return nil, err 64 } 65 return &rv, nil 66 } 67 68 // A collection of arguments for invoking getRouteTable. 69 type LookupRouteTableArgs struct { 70 // Configuration block. Detailed below. 71 Filters []GetRouteTableFilter `pulumi:"filters"` 72 // ID of an Internet Gateway or Virtual Private Gateway which is connected to the Route Table (not exported if not passed as a parameter). 73 GatewayId *string `pulumi:"gatewayId"` 74 // ID of the specific Route Table to retrieve. 75 RouteTableId *string `pulumi:"routeTableId"` 76 // ID of a Subnet which is connected to the Route Table (not exported if not passed as a parameter). 77 SubnetId *string `pulumi:"subnetId"` 78 // Map of tags, each pair of which must exactly match a pair on the desired Route Table. 79 Tags map[string]string `pulumi:"tags"` 80 // ID of the VPC that the desired Route Table belongs to. 81 VpcId *string `pulumi:"vpcId"` 82 } 83 84 // A collection of values returned by getRouteTable. 85 type LookupRouteTableResult struct { 86 // ARN of the route table. 87 Arn string `pulumi:"arn"` 88 // List of associations with attributes detailed below. 89 Associations []GetRouteTableAssociationType `pulumi:"associations"` 90 Filters []GetRouteTableFilter `pulumi:"filters"` 91 // Gateway ID. Only set when associated with an Internet Gateway or Virtual Private Gateway. 92 GatewayId string `pulumi:"gatewayId"` 93 // The provider-assigned unique ID for this managed resource. 94 Id string `pulumi:"id"` 95 // ID of the AWS account that owns the route table. 96 OwnerId string `pulumi:"ownerId"` 97 // Route Table ID. 98 RouteTableId string `pulumi:"routeTableId"` 99 // List of routes with attributes detailed below. 100 Routes []GetRouteTableRoute `pulumi:"routes"` 101 // Subnet ID. Only set when associated with a subnet. 102 SubnetId string `pulumi:"subnetId"` 103 Tags map[string]string `pulumi:"tags"` 104 VpcId string `pulumi:"vpcId"` 105 } 106 107 func LookupRouteTableOutput(ctx *pulumi.Context, args LookupRouteTableOutputArgs, opts ...pulumi.InvokeOption) LookupRouteTableResultOutput { 108 return pulumi.ToOutputWithContext(context.Background(), args). 109 ApplyT(func(v interface{}) (LookupRouteTableResult, error) { 110 args := v.(LookupRouteTableArgs) 111 r, err := LookupRouteTable(ctx, &args, opts...) 112 var s LookupRouteTableResult 113 if r != nil { 114 s = *r 115 } 116 return s, err 117 }).(LookupRouteTableResultOutput) 118 } 119 120 // A collection of arguments for invoking getRouteTable. 121 type LookupRouteTableOutputArgs struct { 122 // Configuration block. Detailed below. 123 Filters GetRouteTableFilterArrayInput `pulumi:"filters"` 124 // ID of an Internet Gateway or Virtual Private Gateway which is connected to the Route Table (not exported if not passed as a parameter). 125 GatewayId pulumi.StringPtrInput `pulumi:"gatewayId"` 126 // ID of the specific Route Table to retrieve. 127 RouteTableId pulumi.StringPtrInput `pulumi:"routeTableId"` 128 // ID of a Subnet which is connected to the Route Table (not exported if not passed as a parameter). 129 SubnetId pulumi.StringPtrInput `pulumi:"subnetId"` 130 // Map of tags, each pair of which must exactly match a pair on the desired Route Table. 131 Tags pulumi.StringMapInput `pulumi:"tags"` 132 // ID of the VPC that the desired Route Table belongs to. 133 VpcId pulumi.StringPtrInput `pulumi:"vpcId"` 134 } 135 136 func (LookupRouteTableOutputArgs) ElementType() reflect.Type { 137 return reflect.TypeOf((*LookupRouteTableArgs)(nil)).Elem() 138 } 139 140 // A collection of values returned by getRouteTable. 141 type LookupRouteTableResultOutput struct{ *pulumi.OutputState } 142 143 func (LookupRouteTableResultOutput) ElementType() reflect.Type { 144 return reflect.TypeOf((*LookupRouteTableResult)(nil)).Elem() 145 } 146 147 func (o LookupRouteTableResultOutput) ToLookupRouteTableResultOutput() LookupRouteTableResultOutput { 148 return o 149 } 150 151 func (o LookupRouteTableResultOutput) ToLookupRouteTableResultOutputWithContext(ctx context.Context) LookupRouteTableResultOutput { 152 return o 153 } 154 155 // ARN of the route table. 156 func (o LookupRouteTableResultOutput) Arn() pulumi.StringOutput { 157 return o.ApplyT(func(v LookupRouteTableResult) string { return v.Arn }).(pulumi.StringOutput) 158 } 159 160 // List of associations with attributes detailed below. 161 func (o LookupRouteTableResultOutput) Associations() GetRouteTableAssociationTypeArrayOutput { 162 return o.ApplyT(func(v LookupRouteTableResult) []GetRouteTableAssociationType { return v.Associations }).(GetRouteTableAssociationTypeArrayOutput) 163 } 164 165 func (o LookupRouteTableResultOutput) Filters() GetRouteTableFilterArrayOutput { 166 return o.ApplyT(func(v LookupRouteTableResult) []GetRouteTableFilter { return v.Filters }).(GetRouteTableFilterArrayOutput) 167 } 168 169 // Gateway ID. Only set when associated with an Internet Gateway or Virtual Private Gateway. 170 func (o LookupRouteTableResultOutput) GatewayId() pulumi.StringOutput { 171 return o.ApplyT(func(v LookupRouteTableResult) string { return v.GatewayId }).(pulumi.StringOutput) 172 } 173 174 // The provider-assigned unique ID for this managed resource. 175 func (o LookupRouteTableResultOutput) Id() pulumi.StringOutput { 176 return o.ApplyT(func(v LookupRouteTableResult) string { return v.Id }).(pulumi.StringOutput) 177 } 178 179 // ID of the AWS account that owns the route table. 180 func (o LookupRouteTableResultOutput) OwnerId() pulumi.StringOutput { 181 return o.ApplyT(func(v LookupRouteTableResult) string { return v.OwnerId }).(pulumi.StringOutput) 182 } 183 184 // Route Table ID. 185 func (o LookupRouteTableResultOutput) RouteTableId() pulumi.StringOutput { 186 return o.ApplyT(func(v LookupRouteTableResult) string { return v.RouteTableId }).(pulumi.StringOutput) 187 } 188 189 // List of routes with attributes detailed below. 190 func (o LookupRouteTableResultOutput) Routes() GetRouteTableRouteArrayOutput { 191 return o.ApplyT(func(v LookupRouteTableResult) []GetRouteTableRoute { return v.Routes }).(GetRouteTableRouteArrayOutput) 192 } 193 194 // Subnet ID. Only set when associated with a subnet. 195 func (o LookupRouteTableResultOutput) SubnetId() pulumi.StringOutput { 196 return o.ApplyT(func(v LookupRouteTableResult) string { return v.SubnetId }).(pulumi.StringOutput) 197 } 198 199 func (o LookupRouteTableResultOutput) Tags() pulumi.StringMapOutput { 200 return o.ApplyT(func(v LookupRouteTableResult) map[string]string { return v.Tags }).(pulumi.StringMapOutput) 201 } 202 203 func (o LookupRouteTableResultOutput) VpcId() pulumi.StringOutput { 204 return o.ApplyT(func(v LookupRouteTableResult) string { return v.VpcId }).(pulumi.StringOutput) 205 } 206 207 func init() { 208 pulumi.RegisterOutputType(LookupRouteTableResultOutput{}) 209 }