-
Notifications
You must be signed in to change notification settings - Fork 151
/
defaultRouteTable.go
354 lines (294 loc) · 13 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
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package ec2
import (
"context"
"reflect"
"github.com/pkg/errors"
"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.
//
// 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
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v4/go/aws/ec2"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := ec2.NewDefaultRouteTable(ctx, "defaultRouteTable", &ec2.DefaultRouteTableArgs{
// DefaultRouteTableId: pulumi.Any(aws_vpc.Foo.Default_route_table_id),
// Routes: ec2.DefaultRouteTableRouteArray{
// nil,
// },
// Tags: pulumi.StringMap{
// "Name": pulumi.String("default table"),
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// Default VPC route tables can be imported using the `vpc_id`, e.g.
//
// ```sh
// $ pulumi import aws:ec2/defaultRouteTable:DefaultRouteTable example vpc-33cc44dd
// ```
//
// [aws-route-tables]http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Route_Tables.html#Route_Replacing_Main_Table [tf-route-tables]/docs/providers/aws/r/route_table.html
type DefaultRouteTable struct {
pulumi.CustomResourceState
// ID of the default route table.
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"`
// Configuration block of routes. Detailed below.
Routes DefaultRouteTableRouteArrayOutput `pulumi:"routes"`
// Map of tags to assign to the resource.
Tags pulumi.StringMapOutput `pulumi:"tags"`
// 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'")
}
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 {
// ID of the default route table.
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"`
// Configuration block of routes. Detailed below.
Routes []DefaultRouteTableRoute `pulumi:"routes"`
// Map of tags to assign to the resource.
Tags map[string]string `pulumi:"tags"`
// ID of the VPC.
VpcId *string `pulumi:"vpcId"`
}
type DefaultRouteTableState struct {
// ID of the default route table.
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
// Configuration block of routes. Detailed below.
Routes DefaultRouteTableRouteArrayInput
// Map of tags to assign to the resource.
Tags 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.
DefaultRouteTableId string `pulumi:"defaultRouteTableId"`
// List of virtual gateways for propagation.
PropagatingVgws []string `pulumi:"propagatingVgws"`
// Configuration block of routes. Detailed below.
Routes []DefaultRouteTableRoute `pulumi:"routes"`
// Map of tags to assign to the resource.
Tags map[string]string `pulumi:"tags"`
}
// The set of arguments for constructing a DefaultRouteTable resource.
type DefaultRouteTableArgs struct {
// ID of the default route table.
DefaultRouteTableId pulumi.StringInput
// List of virtual gateways for propagation.
PropagatingVgws pulumi.StringArrayInput
// Configuration block of routes. Detailed below.
Routes DefaultRouteTableRouteArrayInput
// Map of tags to assign to the resource.
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))
}
func (i *DefaultRouteTable) ToDefaultRouteTableOutput() DefaultRouteTableOutput {
return i.ToDefaultRouteTableOutputWithContext(context.Background())
}
func (i *DefaultRouteTable) ToDefaultRouteTableOutputWithContext(ctx context.Context) DefaultRouteTableOutput {
return pulumi.ToOutputWithContext(ctx, i).(DefaultRouteTableOutput)
}
func (i *DefaultRouteTable) ToDefaultRouteTablePtrOutput() DefaultRouteTablePtrOutput {
return i.ToDefaultRouteTablePtrOutputWithContext(context.Background())
}
func (i *DefaultRouteTable) ToDefaultRouteTablePtrOutputWithContext(ctx context.Context) DefaultRouteTablePtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(DefaultRouteTablePtrOutput)
}
type DefaultRouteTablePtrInput interface {
pulumi.Input
ToDefaultRouteTablePtrOutput() DefaultRouteTablePtrOutput
ToDefaultRouteTablePtrOutputWithContext(ctx context.Context) DefaultRouteTablePtrOutput
}
type defaultRouteTablePtrType DefaultRouteTableArgs
func (*defaultRouteTablePtrType) ElementType() reflect.Type {
return reflect.TypeOf((**DefaultRouteTable)(nil))
}
func (i *defaultRouteTablePtrType) ToDefaultRouteTablePtrOutput() DefaultRouteTablePtrOutput {
return i.ToDefaultRouteTablePtrOutputWithContext(context.Background())
}
func (i *defaultRouteTablePtrType) ToDefaultRouteTablePtrOutputWithContext(ctx context.Context) DefaultRouteTablePtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(DefaultRouteTablePtrOutput)
}
// 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))
}
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))
}
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))
}
func (o DefaultRouteTableOutput) ToDefaultRouteTableOutput() DefaultRouteTableOutput {
return o
}
func (o DefaultRouteTableOutput) ToDefaultRouteTableOutputWithContext(ctx context.Context) DefaultRouteTableOutput {
return o
}
func (o DefaultRouteTableOutput) ToDefaultRouteTablePtrOutput() DefaultRouteTablePtrOutput {
return o.ToDefaultRouteTablePtrOutputWithContext(context.Background())
}
func (o DefaultRouteTableOutput) ToDefaultRouteTablePtrOutputWithContext(ctx context.Context) DefaultRouteTablePtrOutput {
return o.ApplyT(func(v DefaultRouteTable) *DefaultRouteTable {
return &v
}).(DefaultRouteTablePtrOutput)
}
type DefaultRouteTablePtrOutput struct {
*pulumi.OutputState
}
func (DefaultRouteTablePtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**DefaultRouteTable)(nil))
}
func (o DefaultRouteTablePtrOutput) ToDefaultRouteTablePtrOutput() DefaultRouteTablePtrOutput {
return o
}
func (o DefaultRouteTablePtrOutput) ToDefaultRouteTablePtrOutputWithContext(ctx context.Context) DefaultRouteTablePtrOutput {
return o
}
type DefaultRouteTableArrayOutput struct{ *pulumi.OutputState }
func (DefaultRouteTableArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]DefaultRouteTable)(nil))
}
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))
}
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.RegisterOutputType(DefaultRouteTableOutput{})
pulumi.RegisterOutputType(DefaultRouteTablePtrOutput{})
pulumi.RegisterOutputType(DefaultRouteTableArrayOutput{})
pulumi.RegisterOutputType(DefaultRouteTableMapOutput{})
}