github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/ec2/routeTable.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 "errors" 11 "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal" 12 "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 13 ) 14 15 // Provides a resource to create a VPC routing table. 16 // 17 // > **NOTE on Route Tables and Routes:** This provider currently 18 // provides both a standalone Route resource and a Route Table resource with routes 19 // defined in-line. At this time you cannot use a Route Table with in-line routes 20 // in conjunction with any Route resources. Doing so will cause 21 // a conflict of rule settings and will overwrite rules. 22 // 23 // > **NOTE on `gatewayId` and `natGatewayId`:** The AWS API is very forgiving with these two 24 // attributes and the `ec2.RouteTable` resource can be created with a NAT ID specified as a Gateway ID attribute. 25 // This _will_ lead to a permanent diff between your configuration and statefile, as the API returns the correct 26 // parameters in the returned route table. If you're experiencing constant diffs in your `ec2.RouteTable` resources, 27 // the first thing to check is whether or not you're specifying a NAT ID instead of a Gateway ID, or vice-versa. 28 // 29 // > **NOTE on `propagatingVgws` and the `ec2.VpnGatewayRoutePropagation` resource:** 30 // If the `propagatingVgws` argument is present, it's not supported to _also_ 31 // define route propagations using `ec2.VpnGatewayRoutePropagation`, since 32 // this resource will delete any propagating gateways not explicitly listed in 33 // `propagatingVgws`. Omit this argument when defining route propagation using 34 // the separate resource. 35 // 36 // ## Example Usage 37 // 38 // ### Basic example 39 // 40 // <!--Start PulumiCodeChooser --> 41 // ```go 42 // package main 43 // 44 // import ( 45 // 46 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2" 47 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 48 // 49 // ) 50 // 51 // func main() { 52 // pulumi.Run(func(ctx *pulumi.Context) error { 53 // _, err := ec2.NewRouteTable(ctx, "example", &ec2.RouteTableArgs{ 54 // VpcId: pulumi.Any(exampleAwsVpc.Id), 55 // Routes: ec2.RouteTableRouteArray{ 56 // &ec2.RouteTableRouteArgs{ 57 // CidrBlock: pulumi.String("10.0.1.0/24"), 58 // GatewayId: pulumi.Any(exampleAwsInternetGateway.Id), 59 // }, 60 // &ec2.RouteTableRouteArgs{ 61 // Ipv6CidrBlock: pulumi.String("::/0"), 62 // EgressOnlyGatewayId: pulumi.Any(exampleAwsEgressOnlyInternetGateway.Id), 63 // }, 64 // }, 65 // Tags: pulumi.StringMap{ 66 // "Name": pulumi.String("example"), 67 // }, 68 // }) 69 // if err != nil { 70 // return err 71 // } 72 // return nil 73 // }) 74 // } 75 // 76 // ``` 77 // <!--End PulumiCodeChooser --> 78 // 79 // To subsequently remove all managed routes: 80 // 81 // <!--Start PulumiCodeChooser --> 82 // ```go 83 // package main 84 // 85 // import ( 86 // 87 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2" 88 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 89 // 90 // ) 91 // 92 // func main() { 93 // pulumi.Run(func(ctx *pulumi.Context) error { 94 // _, err := ec2.NewRouteTable(ctx, "example", &ec2.RouteTableArgs{ 95 // VpcId: pulumi.Any(exampleAwsVpc.Id), 96 // Routes: ec2.RouteTableRouteArray{}, 97 // Tags: pulumi.StringMap{ 98 // "Name": pulumi.String("example"), 99 // }, 100 // }) 101 // if err != nil { 102 // return err 103 // } 104 // return nil 105 // }) 106 // } 107 // 108 // ``` 109 // <!--End PulumiCodeChooser --> 110 // 111 // ### Adopting an existing local route 112 // 113 // AWS creates certain routes that the AWS provider mostly ignores. You can manage them by importing or adopting them. See Import below for information on importing. This example shows adopting a route and then updating its target. 114 // 115 // First, adopt an existing AWS-created route: 116 // 117 // <!--Start PulumiCodeChooser --> 118 // ```go 119 // package main 120 // 121 // import ( 122 // 123 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2" 124 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 125 // 126 // ) 127 // 128 // func main() { 129 // pulumi.Run(func(ctx *pulumi.Context) error { 130 // test, err := ec2.NewVpc(ctx, "test", &ec2.VpcArgs{ 131 // CidrBlock: pulumi.String("10.1.0.0/16"), 132 // }) 133 // if err != nil { 134 // return err 135 // } 136 // _, err = ec2.NewRouteTable(ctx, "test", &ec2.RouteTableArgs{ 137 // VpcId: test.ID(), 138 // Routes: ec2.RouteTableRouteArray{ 139 // &ec2.RouteTableRouteArgs{ 140 // CidrBlock: pulumi.String("10.1.0.0/16"), 141 // GatewayId: pulumi.String("local"), 142 // }, 143 // }, 144 // }) 145 // if err != nil { 146 // return err 147 // } 148 // return nil 149 // }) 150 // } 151 // 152 // ``` 153 // <!--End PulumiCodeChooser --> 154 // 155 // Next, update the target of the route: 156 // 157 // <!--Start PulumiCodeChooser --> 158 // ```go 159 // package main 160 // 161 // import ( 162 // 163 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2" 164 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 165 // 166 // ) 167 // 168 // func main() { 169 // pulumi.Run(func(ctx *pulumi.Context) error { 170 // test, err := ec2.NewVpc(ctx, "test", &ec2.VpcArgs{ 171 // CidrBlock: pulumi.String("10.1.0.0/16"), 172 // }) 173 // if err != nil { 174 // return err 175 // } 176 // testSubnet, err := ec2.NewSubnet(ctx, "test", &ec2.SubnetArgs{ 177 // CidrBlock: pulumi.String("10.1.1.0/24"), 178 // VpcId: test.ID(), 179 // }) 180 // if err != nil { 181 // return err 182 // } 183 // testNetworkInterface, err := ec2.NewNetworkInterface(ctx, "test", &ec2.NetworkInterfaceArgs{ 184 // SubnetId: testSubnet.ID(), 185 // }) 186 // if err != nil { 187 // return err 188 // } 189 // _, err = ec2.NewRouteTable(ctx, "test", &ec2.RouteTableArgs{ 190 // VpcId: test.ID(), 191 // Routes: ec2.RouteTableRouteArray{ 192 // &ec2.RouteTableRouteArgs{ 193 // CidrBlock: test.CidrBlock, 194 // NetworkInterfaceId: testNetworkInterface.ID(), 195 // }, 196 // }, 197 // }) 198 // if err != nil { 199 // return err 200 // } 201 // return nil 202 // }) 203 // } 204 // 205 // ``` 206 // <!--End PulumiCodeChooser --> 207 // 208 // The target could then be updated again back to `local`. 209 // 210 // ## Import 211 // 212 // Using `pulumi import`, import Route Tables using the route table `id`. For example: 213 // 214 // ```sh 215 // $ pulumi import aws:ec2/routeTable:RouteTable public_rt rtb-4e616f6d69 216 // ``` 217 type RouteTable struct { 218 pulumi.CustomResourceState 219 220 // The ARN of the route table. 221 Arn pulumi.StringOutput `pulumi:"arn"` 222 // The ID of the AWS account that owns the route table. 223 OwnerId pulumi.StringOutput `pulumi:"ownerId"` 224 // A list of virtual gateways for propagation. 225 PropagatingVgws pulumi.StringArrayOutput `pulumi:"propagatingVgws"` 226 // A list of route objects. Their keys are documented below. 227 // This means that omitting this argument is interpreted as ignoring any existing routes. To remove all managed routes an empty list should be specified. See the example above. 228 Routes RouteTableRouteArrayOutput `pulumi:"routes"` 229 // A map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. 230 Tags pulumi.StringMapOutput `pulumi:"tags"` 231 // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 232 // 233 // Deprecated: Please use `tags` instead. 234 TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"` 235 // The VPC ID. 236 VpcId pulumi.StringOutput `pulumi:"vpcId"` 237 } 238 239 // NewRouteTable registers a new resource with the given unique name, arguments, and options. 240 func NewRouteTable(ctx *pulumi.Context, 241 name string, args *RouteTableArgs, opts ...pulumi.ResourceOption) (*RouteTable, error) { 242 if args == nil { 243 return nil, errors.New("missing one or more required arguments") 244 } 245 246 if args.VpcId == nil { 247 return nil, errors.New("invalid value for required argument 'VpcId'") 248 } 249 opts = internal.PkgResourceDefaultOpts(opts) 250 var resource RouteTable 251 err := ctx.RegisterResource("aws:ec2/routeTable:RouteTable", name, args, &resource, opts...) 252 if err != nil { 253 return nil, err 254 } 255 return &resource, nil 256 } 257 258 // GetRouteTable gets an existing RouteTable resource's state with the given name, ID, and optional 259 // state properties that are used to uniquely qualify the lookup (nil if not required). 260 func GetRouteTable(ctx *pulumi.Context, 261 name string, id pulumi.IDInput, state *RouteTableState, opts ...pulumi.ResourceOption) (*RouteTable, error) { 262 var resource RouteTable 263 err := ctx.ReadResource("aws:ec2/routeTable:RouteTable", name, id, state, &resource, opts...) 264 if err != nil { 265 return nil, err 266 } 267 return &resource, nil 268 } 269 270 // Input properties used for looking up and filtering RouteTable resources. 271 type routeTableState struct { 272 // The ARN of the route table. 273 Arn *string `pulumi:"arn"` 274 // The ID of the AWS account that owns the route table. 275 OwnerId *string `pulumi:"ownerId"` 276 // A list of virtual gateways for propagation. 277 PropagatingVgws []string `pulumi:"propagatingVgws"` 278 // A list of route objects. Their keys are documented below. 279 // This means that omitting this argument is interpreted as ignoring any existing routes. To remove all managed routes an empty list should be specified. See the example above. 280 Routes []RouteTableRoute `pulumi:"routes"` 281 // A map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. 282 Tags map[string]string `pulumi:"tags"` 283 // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 284 // 285 // Deprecated: Please use `tags` instead. 286 TagsAll map[string]string `pulumi:"tagsAll"` 287 // The VPC ID. 288 VpcId *string `pulumi:"vpcId"` 289 } 290 291 type RouteTableState struct { 292 // The ARN of the route table. 293 Arn pulumi.StringPtrInput 294 // The ID of the AWS account that owns the route table. 295 OwnerId pulumi.StringPtrInput 296 // A list of virtual gateways for propagation. 297 PropagatingVgws pulumi.StringArrayInput 298 // A list of route objects. Their keys are documented below. 299 // This means that omitting this argument is interpreted as ignoring any existing routes. To remove all managed routes an empty list should be specified. See the example above. 300 Routes RouteTableRouteArrayInput 301 // A map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. 302 Tags pulumi.StringMapInput 303 // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 304 // 305 // Deprecated: Please use `tags` instead. 306 TagsAll pulumi.StringMapInput 307 // The VPC ID. 308 VpcId pulumi.StringPtrInput 309 } 310 311 func (RouteTableState) ElementType() reflect.Type { 312 return reflect.TypeOf((*routeTableState)(nil)).Elem() 313 } 314 315 type routeTableArgs struct { 316 // A list of virtual gateways for propagation. 317 PropagatingVgws []string `pulumi:"propagatingVgws"` 318 // A list of route objects. Their keys are documented below. 319 // This means that omitting this argument is interpreted as ignoring any existing routes. To remove all managed routes an empty list should be specified. See the example above. 320 Routes []RouteTableRoute `pulumi:"routes"` 321 // A map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. 322 Tags map[string]string `pulumi:"tags"` 323 // The VPC ID. 324 VpcId string `pulumi:"vpcId"` 325 } 326 327 // The set of arguments for constructing a RouteTable resource. 328 type RouteTableArgs struct { 329 // A list of virtual gateways for propagation. 330 PropagatingVgws pulumi.StringArrayInput 331 // A list of route objects. Their keys are documented below. 332 // This means that omitting this argument is interpreted as ignoring any existing routes. To remove all managed routes an empty list should be specified. See the example above. 333 Routes RouteTableRouteArrayInput 334 // A map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. 335 Tags pulumi.StringMapInput 336 // The VPC ID. 337 VpcId pulumi.StringInput 338 } 339 340 func (RouteTableArgs) ElementType() reflect.Type { 341 return reflect.TypeOf((*routeTableArgs)(nil)).Elem() 342 } 343 344 type RouteTableInput interface { 345 pulumi.Input 346 347 ToRouteTableOutput() RouteTableOutput 348 ToRouteTableOutputWithContext(ctx context.Context) RouteTableOutput 349 } 350 351 func (*RouteTable) ElementType() reflect.Type { 352 return reflect.TypeOf((**RouteTable)(nil)).Elem() 353 } 354 355 func (i *RouteTable) ToRouteTableOutput() RouteTableOutput { 356 return i.ToRouteTableOutputWithContext(context.Background()) 357 } 358 359 func (i *RouteTable) ToRouteTableOutputWithContext(ctx context.Context) RouteTableOutput { 360 return pulumi.ToOutputWithContext(ctx, i).(RouteTableOutput) 361 } 362 363 // RouteTableArrayInput is an input type that accepts RouteTableArray and RouteTableArrayOutput values. 364 // You can construct a concrete instance of `RouteTableArrayInput` via: 365 // 366 // RouteTableArray{ RouteTableArgs{...} } 367 type RouteTableArrayInput interface { 368 pulumi.Input 369 370 ToRouteTableArrayOutput() RouteTableArrayOutput 371 ToRouteTableArrayOutputWithContext(context.Context) RouteTableArrayOutput 372 } 373 374 type RouteTableArray []RouteTableInput 375 376 func (RouteTableArray) ElementType() reflect.Type { 377 return reflect.TypeOf((*[]*RouteTable)(nil)).Elem() 378 } 379 380 func (i RouteTableArray) ToRouteTableArrayOutput() RouteTableArrayOutput { 381 return i.ToRouteTableArrayOutputWithContext(context.Background()) 382 } 383 384 func (i RouteTableArray) ToRouteTableArrayOutputWithContext(ctx context.Context) RouteTableArrayOutput { 385 return pulumi.ToOutputWithContext(ctx, i).(RouteTableArrayOutput) 386 } 387 388 // RouteTableMapInput is an input type that accepts RouteTableMap and RouteTableMapOutput values. 389 // You can construct a concrete instance of `RouteTableMapInput` via: 390 // 391 // RouteTableMap{ "key": RouteTableArgs{...} } 392 type RouteTableMapInput interface { 393 pulumi.Input 394 395 ToRouteTableMapOutput() RouteTableMapOutput 396 ToRouteTableMapOutputWithContext(context.Context) RouteTableMapOutput 397 } 398 399 type RouteTableMap map[string]RouteTableInput 400 401 func (RouteTableMap) ElementType() reflect.Type { 402 return reflect.TypeOf((*map[string]*RouteTable)(nil)).Elem() 403 } 404 405 func (i RouteTableMap) ToRouteTableMapOutput() RouteTableMapOutput { 406 return i.ToRouteTableMapOutputWithContext(context.Background()) 407 } 408 409 func (i RouteTableMap) ToRouteTableMapOutputWithContext(ctx context.Context) RouteTableMapOutput { 410 return pulumi.ToOutputWithContext(ctx, i).(RouteTableMapOutput) 411 } 412 413 type RouteTableOutput struct{ *pulumi.OutputState } 414 415 func (RouteTableOutput) ElementType() reflect.Type { 416 return reflect.TypeOf((**RouteTable)(nil)).Elem() 417 } 418 419 func (o RouteTableOutput) ToRouteTableOutput() RouteTableOutput { 420 return o 421 } 422 423 func (o RouteTableOutput) ToRouteTableOutputWithContext(ctx context.Context) RouteTableOutput { 424 return o 425 } 426 427 // The ARN of the route table. 428 func (o RouteTableOutput) Arn() pulumi.StringOutput { 429 return o.ApplyT(func(v *RouteTable) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput) 430 } 431 432 // The ID of the AWS account that owns the route table. 433 func (o RouteTableOutput) OwnerId() pulumi.StringOutput { 434 return o.ApplyT(func(v *RouteTable) pulumi.StringOutput { return v.OwnerId }).(pulumi.StringOutput) 435 } 436 437 // A list of virtual gateways for propagation. 438 func (o RouteTableOutput) PropagatingVgws() pulumi.StringArrayOutput { 439 return o.ApplyT(func(v *RouteTable) pulumi.StringArrayOutput { return v.PropagatingVgws }).(pulumi.StringArrayOutput) 440 } 441 442 // A list of route objects. Their keys are documented below. 443 // This means that omitting this argument is interpreted as ignoring any existing routes. To remove all managed routes an empty list should be specified. See the example above. 444 func (o RouteTableOutput) Routes() RouteTableRouteArrayOutput { 445 return o.ApplyT(func(v *RouteTable) RouteTableRouteArrayOutput { return v.Routes }).(RouteTableRouteArrayOutput) 446 } 447 448 // A map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. 449 func (o RouteTableOutput) Tags() pulumi.StringMapOutput { 450 return o.ApplyT(func(v *RouteTable) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput) 451 } 452 453 // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 454 // 455 // Deprecated: Please use `tags` instead. 456 func (o RouteTableOutput) TagsAll() pulumi.StringMapOutput { 457 return o.ApplyT(func(v *RouteTable) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput) 458 } 459 460 // The VPC ID. 461 func (o RouteTableOutput) VpcId() pulumi.StringOutput { 462 return o.ApplyT(func(v *RouteTable) pulumi.StringOutput { return v.VpcId }).(pulumi.StringOutput) 463 } 464 465 type RouteTableArrayOutput struct{ *pulumi.OutputState } 466 467 func (RouteTableArrayOutput) ElementType() reflect.Type { 468 return reflect.TypeOf((*[]*RouteTable)(nil)).Elem() 469 } 470 471 func (o RouteTableArrayOutput) ToRouteTableArrayOutput() RouteTableArrayOutput { 472 return o 473 } 474 475 func (o RouteTableArrayOutput) ToRouteTableArrayOutputWithContext(ctx context.Context) RouteTableArrayOutput { 476 return o 477 } 478 479 func (o RouteTableArrayOutput) Index(i pulumi.IntInput) RouteTableOutput { 480 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *RouteTable { 481 return vs[0].([]*RouteTable)[vs[1].(int)] 482 }).(RouteTableOutput) 483 } 484 485 type RouteTableMapOutput struct{ *pulumi.OutputState } 486 487 func (RouteTableMapOutput) ElementType() reflect.Type { 488 return reflect.TypeOf((*map[string]*RouteTable)(nil)).Elem() 489 } 490 491 func (o RouteTableMapOutput) ToRouteTableMapOutput() RouteTableMapOutput { 492 return o 493 } 494 495 func (o RouteTableMapOutput) ToRouteTableMapOutputWithContext(ctx context.Context) RouteTableMapOutput { 496 return o 497 } 498 499 func (o RouteTableMapOutput) MapIndex(k pulumi.StringInput) RouteTableOutput { 500 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *RouteTable { 501 return vs[0].(map[string]*RouteTable)[vs[1].(string)] 502 }).(RouteTableOutput) 503 } 504 505 func init() { 506 pulumi.RegisterInputType(reflect.TypeOf((*RouteTableInput)(nil)).Elem(), &RouteTable{}) 507 pulumi.RegisterInputType(reflect.TypeOf((*RouteTableArrayInput)(nil)).Elem(), RouteTableArray{}) 508 pulumi.RegisterInputType(reflect.TypeOf((*RouteTableMapInput)(nil)).Elem(), RouteTableMap{}) 509 pulumi.RegisterOutputType(RouteTableOutput{}) 510 pulumi.RegisterOutputType(RouteTableArrayOutput{}) 511 pulumi.RegisterOutputType(RouteTableMapOutput{}) 512 }