/
defaultRouteTable.go
415 lines (361 loc) · 16.3 KB
/
defaultRouteTable.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
// Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package ec2
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Provides a resource to manage a default route table of a VPC. This resource can manage the default route table of the default or a non-default VPC.
//
// > **NOTE:** This is an advanced resource with special caveats. Please read this document in its entirety before using this resource. The `ec2.DefaultRouteTable` resource behaves differently from normal resources. This provider does not _create_ this resource but instead attempts to "adopt" it into management. **Do not** use both `ec2.DefaultRouteTable` to manage a default route table **and** `ec2.MainRouteTableAssociation` with the same VPC due to possible route conflicts. See ec2.MainRouteTableAssociation documentation for more details.
//
// Every VPC has a default route table that can be managed but not destroyed. When the provider first adopts a default route table, it **immediately removes all defined routes**. It then proceeds to create any routes specified in the configuration. This step is required so that only the routes specified in the configuration exist in the default route table.
//
// For more information, see the Amazon VPC User Guide on [Route Tables](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Route_Tables.html). For information about managing normal route tables in this provider, see `ec2.RouteTable`.
//
// ## Example Usage
//
// <!--Start PulumiCodeChooser -->
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := ec2.NewDefaultRouteTable(ctx, "example", &ec2.DefaultRouteTableArgs{
// DefaultRouteTableId: pulumi.Any(exampleAwsVpc.DefaultRouteTableId),
// Routes: ec2.DefaultRouteTableRouteArray{
// &ec2.DefaultRouteTableRouteArgs{
// CidrBlock: pulumi.String("10.0.1.0/24"),
// GatewayId: pulumi.Any(exampleAwsInternetGateway.Id),
// },
// &ec2.DefaultRouteTableRouteArgs{
// Ipv6CidrBlock: pulumi.String("::/0"),
// EgressOnlyGatewayId: pulumi.Any(exampleAwsEgressOnlyInternetGateway.Id),
// },
// },
// Tags: pulumi.StringMap{
// "Name": pulumi.String("example"),
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// <!--End PulumiCodeChooser -->
//
// To subsequently remove all managed routes:
//
// <!--Start PulumiCodeChooser -->
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := ec2.NewDefaultRouteTable(ctx, "example", &ec2.DefaultRouteTableArgs{
// DefaultRouteTableId: pulumi.Any(exampleAwsVpc.DefaultRouteTableId),
// Routes: ec2.DefaultRouteTableRouteArray{},
// Tags: pulumi.StringMap{
// "Name": pulumi.String("example"),
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// <!--End PulumiCodeChooser -->
//
// ## Import
//
// Using `pulumi import`, import Default VPC route tables using the `vpc_id`. For example:
//
// ```sh
// $ pulumi import aws:ec2/defaultRouteTable:DefaultRouteTable example vpc-33cc44dd
// ```
type DefaultRouteTable struct {
pulumi.CustomResourceState
// The ARN of the route table.
Arn pulumi.StringOutput `pulumi:"arn"`
// ID of the default route table.
//
// The following arguments are optional:
DefaultRouteTableId pulumi.StringOutput `pulumi:"defaultRouteTableId"`
// ID of the AWS account that owns the route table.
OwnerId pulumi.StringOutput `pulumi:"ownerId"`
// List of virtual gateways for propagation.
PropagatingVgws pulumi.StringArrayOutput `pulumi:"propagatingVgws"`
// Set of objects. Detailed below
Routes DefaultRouteTableRouteArrayOutput `pulumi:"routes"`
// 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.
Tags pulumi.StringMapOutput `pulumi:"tags"`
// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
//
// Deprecated: Please use `tags` instead.
TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"`
// ID of the VPC.
VpcId pulumi.StringOutput `pulumi:"vpcId"`
}
// NewDefaultRouteTable registers a new resource with the given unique name, arguments, and options.
func NewDefaultRouteTable(ctx *pulumi.Context,
name string, args *DefaultRouteTableArgs, opts ...pulumi.ResourceOption) (*DefaultRouteTable, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.DefaultRouteTableId == nil {
return nil, errors.New("invalid value for required argument 'DefaultRouteTableId'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource DefaultRouteTable
err := ctx.RegisterResource("aws:ec2/defaultRouteTable:DefaultRouteTable", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetDefaultRouteTable gets an existing DefaultRouteTable resource's state with the given name, ID, and optional
// state properties that are used to uniquely qualify the lookup (nil if not required).
func GetDefaultRouteTable(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *DefaultRouteTableState, opts ...pulumi.ResourceOption) (*DefaultRouteTable, error) {
var resource DefaultRouteTable
err := ctx.ReadResource("aws:ec2/defaultRouteTable:DefaultRouteTable", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering DefaultRouteTable resources.
type defaultRouteTableState struct {
// The ARN of the route table.
Arn *string `pulumi:"arn"`
// ID of the default route table.
//
// The following arguments are optional:
DefaultRouteTableId *string `pulumi:"defaultRouteTableId"`
// ID of the AWS account that owns the route table.
OwnerId *string `pulumi:"ownerId"`
// List of virtual gateways for propagation.
PropagatingVgws []string `pulumi:"propagatingVgws"`
// Set of objects. Detailed below
Routes []DefaultRouteTableRoute `pulumi:"routes"`
// 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.
Tags map[string]string `pulumi:"tags"`
// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
//
// Deprecated: Please use `tags` instead.
TagsAll map[string]string `pulumi:"tagsAll"`
// ID of the VPC.
VpcId *string `pulumi:"vpcId"`
}
type DefaultRouteTableState struct {
// The ARN of the route table.
Arn pulumi.StringPtrInput
// ID of the default route table.
//
// The following arguments are optional:
DefaultRouteTableId pulumi.StringPtrInput
// ID of the AWS account that owns the route table.
OwnerId pulumi.StringPtrInput
// List of virtual gateways for propagation.
PropagatingVgws pulumi.StringArrayInput
// Set of objects. Detailed below
Routes DefaultRouteTableRouteArrayInput
// 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.
Tags pulumi.StringMapInput
// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
//
// Deprecated: Please use `tags` instead.
TagsAll pulumi.StringMapInput
// ID of the VPC.
VpcId pulumi.StringPtrInput
}
func (DefaultRouteTableState) ElementType() reflect.Type {
return reflect.TypeOf((*defaultRouteTableState)(nil)).Elem()
}
type defaultRouteTableArgs struct {
// ID of the default route table.
//
// The following arguments are optional:
DefaultRouteTableId string `pulumi:"defaultRouteTableId"`
// List of virtual gateways for propagation.
PropagatingVgws []string `pulumi:"propagatingVgws"`
// Set of objects. Detailed below
Routes []DefaultRouteTableRoute `pulumi:"routes"`
// 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.
Tags map[string]string `pulumi:"tags"`
}
// The set of arguments for constructing a DefaultRouteTable resource.
type DefaultRouteTableArgs struct {
// ID of the default route table.
//
// The following arguments are optional:
DefaultRouteTableId pulumi.StringInput
// List of virtual gateways for propagation.
PropagatingVgws pulumi.StringArrayInput
// Set of objects. Detailed below
Routes DefaultRouteTableRouteArrayInput
// 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.
Tags pulumi.StringMapInput
}
func (DefaultRouteTableArgs) ElementType() reflect.Type {
return reflect.TypeOf((*defaultRouteTableArgs)(nil)).Elem()
}
type DefaultRouteTableInput interface {
pulumi.Input
ToDefaultRouteTableOutput() DefaultRouteTableOutput
ToDefaultRouteTableOutputWithContext(ctx context.Context) DefaultRouteTableOutput
}
func (*DefaultRouteTable) ElementType() reflect.Type {
return reflect.TypeOf((**DefaultRouteTable)(nil)).Elem()
}
func (i *DefaultRouteTable) ToDefaultRouteTableOutput() DefaultRouteTableOutput {
return i.ToDefaultRouteTableOutputWithContext(context.Background())
}
func (i *DefaultRouteTable) ToDefaultRouteTableOutputWithContext(ctx context.Context) DefaultRouteTableOutput {
return pulumi.ToOutputWithContext(ctx, i).(DefaultRouteTableOutput)
}
// DefaultRouteTableArrayInput is an input type that accepts DefaultRouteTableArray and DefaultRouteTableArrayOutput values.
// You can construct a concrete instance of `DefaultRouteTableArrayInput` via:
//
// DefaultRouteTableArray{ DefaultRouteTableArgs{...} }
type DefaultRouteTableArrayInput interface {
pulumi.Input
ToDefaultRouteTableArrayOutput() DefaultRouteTableArrayOutput
ToDefaultRouteTableArrayOutputWithContext(context.Context) DefaultRouteTableArrayOutput
}
type DefaultRouteTableArray []DefaultRouteTableInput
func (DefaultRouteTableArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*DefaultRouteTable)(nil)).Elem()
}
func (i DefaultRouteTableArray) ToDefaultRouteTableArrayOutput() DefaultRouteTableArrayOutput {
return i.ToDefaultRouteTableArrayOutputWithContext(context.Background())
}
func (i DefaultRouteTableArray) ToDefaultRouteTableArrayOutputWithContext(ctx context.Context) DefaultRouteTableArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(DefaultRouteTableArrayOutput)
}
// DefaultRouteTableMapInput is an input type that accepts DefaultRouteTableMap and DefaultRouteTableMapOutput values.
// You can construct a concrete instance of `DefaultRouteTableMapInput` via:
//
// DefaultRouteTableMap{ "key": DefaultRouteTableArgs{...} }
type DefaultRouteTableMapInput interface {
pulumi.Input
ToDefaultRouteTableMapOutput() DefaultRouteTableMapOutput
ToDefaultRouteTableMapOutputWithContext(context.Context) DefaultRouteTableMapOutput
}
type DefaultRouteTableMap map[string]DefaultRouteTableInput
func (DefaultRouteTableMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*DefaultRouteTable)(nil)).Elem()
}
func (i DefaultRouteTableMap) ToDefaultRouteTableMapOutput() DefaultRouteTableMapOutput {
return i.ToDefaultRouteTableMapOutputWithContext(context.Background())
}
func (i DefaultRouteTableMap) ToDefaultRouteTableMapOutputWithContext(ctx context.Context) DefaultRouteTableMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(DefaultRouteTableMapOutput)
}
type DefaultRouteTableOutput struct{ *pulumi.OutputState }
func (DefaultRouteTableOutput) ElementType() reflect.Type {
return reflect.TypeOf((**DefaultRouteTable)(nil)).Elem()
}
func (o DefaultRouteTableOutput) ToDefaultRouteTableOutput() DefaultRouteTableOutput {
return o
}
func (o DefaultRouteTableOutput) ToDefaultRouteTableOutputWithContext(ctx context.Context) DefaultRouteTableOutput {
return o
}
// The ARN of the route table.
func (o DefaultRouteTableOutput) Arn() pulumi.StringOutput {
return o.ApplyT(func(v *DefaultRouteTable) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput)
}
// ID of the default route table.
//
// The following arguments are optional:
func (o DefaultRouteTableOutput) DefaultRouteTableId() pulumi.StringOutput {
return o.ApplyT(func(v *DefaultRouteTable) pulumi.StringOutput { return v.DefaultRouteTableId }).(pulumi.StringOutput)
}
// ID of the AWS account that owns the route table.
func (o DefaultRouteTableOutput) OwnerId() pulumi.StringOutput {
return o.ApplyT(func(v *DefaultRouteTable) pulumi.StringOutput { return v.OwnerId }).(pulumi.StringOutput)
}
// List of virtual gateways for propagation.
func (o DefaultRouteTableOutput) PropagatingVgws() pulumi.StringArrayOutput {
return o.ApplyT(func(v *DefaultRouteTable) pulumi.StringArrayOutput { return v.PropagatingVgws }).(pulumi.StringArrayOutput)
}
// Set of objects. Detailed below
func (o DefaultRouteTableOutput) Routes() DefaultRouteTableRouteArrayOutput {
return o.ApplyT(func(v *DefaultRouteTable) DefaultRouteTableRouteArrayOutput { return v.Routes }).(DefaultRouteTableRouteArrayOutput)
}
// 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.
func (o DefaultRouteTableOutput) Tags() pulumi.StringMapOutput {
return o.ApplyT(func(v *DefaultRouteTable) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)
}
// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
//
// Deprecated: Please use `tags` instead.
func (o DefaultRouteTableOutput) TagsAll() pulumi.StringMapOutput {
return o.ApplyT(func(v *DefaultRouteTable) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput)
}
// ID of the VPC.
func (o DefaultRouteTableOutput) VpcId() pulumi.StringOutput {
return o.ApplyT(func(v *DefaultRouteTable) pulumi.StringOutput { return v.VpcId }).(pulumi.StringOutput)
}
type DefaultRouteTableArrayOutput struct{ *pulumi.OutputState }
func (DefaultRouteTableArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*DefaultRouteTable)(nil)).Elem()
}
func (o DefaultRouteTableArrayOutput) ToDefaultRouteTableArrayOutput() DefaultRouteTableArrayOutput {
return o
}
func (o DefaultRouteTableArrayOutput) ToDefaultRouteTableArrayOutputWithContext(ctx context.Context) DefaultRouteTableArrayOutput {
return o
}
func (o DefaultRouteTableArrayOutput) Index(i pulumi.IntInput) DefaultRouteTableOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *DefaultRouteTable {
return vs[0].([]*DefaultRouteTable)[vs[1].(int)]
}).(DefaultRouteTableOutput)
}
type DefaultRouteTableMapOutput struct{ *pulumi.OutputState }
func (DefaultRouteTableMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*DefaultRouteTable)(nil)).Elem()
}
func (o DefaultRouteTableMapOutput) ToDefaultRouteTableMapOutput() DefaultRouteTableMapOutput {
return o
}
func (o DefaultRouteTableMapOutput) ToDefaultRouteTableMapOutputWithContext(ctx context.Context) DefaultRouteTableMapOutput {
return o
}
func (o DefaultRouteTableMapOutput) MapIndex(k pulumi.StringInput) DefaultRouteTableOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *DefaultRouteTable {
return vs[0].(map[string]*DefaultRouteTable)[vs[1].(string)]
}).(DefaultRouteTableOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*DefaultRouteTableInput)(nil)).Elem(), &DefaultRouteTable{})
pulumi.RegisterInputType(reflect.TypeOf((*DefaultRouteTableArrayInput)(nil)).Elem(), DefaultRouteTableArray{})
pulumi.RegisterInputType(reflect.TypeOf((*DefaultRouteTableMapInput)(nil)).Elem(), DefaultRouteTableMap{})
pulumi.RegisterOutputType(DefaultRouteTableOutput{})
pulumi.RegisterOutputType(DefaultRouteTableArrayOutput{})
pulumi.RegisterOutputType(DefaultRouteTableMapOutput{})
}