/
route.go
355 lines (303 loc) · 12.2 KB
/
route.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
// 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 ec2clientvpn
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Provides additional routes for AWS Client VPN endpoints. For more information on usage, please see the
// [AWS Client VPN Administrator's Guide](https://docs.aws.amazon.com/vpn/latest/clientvpn-admin/what-is.html).
//
// ## Example Usage
//
// <!--Start PulumiCodeChooser -->
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2clientvpn"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// exampleEndpoint, err := ec2clientvpn.NewEndpoint(ctx, "example", &ec2clientvpn.EndpointArgs{
// Description: pulumi.String("Example Client VPN endpoint"),
// ServerCertificateArn: pulumi.Any(exampleAwsAcmCertificate.Arn),
// ClientCidrBlock: pulumi.String("10.0.0.0/16"),
// AuthenticationOptions: ec2clientvpn.EndpointAuthenticationOptionArray{
// &ec2clientvpn.EndpointAuthenticationOptionArgs{
// Type: pulumi.String("certificate-authentication"),
// RootCertificateChainArn: pulumi.Any(exampleAwsAcmCertificate.Arn),
// },
// },
// ConnectionLogOptions: &ec2clientvpn.EndpointConnectionLogOptionsArgs{
// Enabled: pulumi.Bool(false),
// },
// })
// if err != nil {
// return err
// }
// exampleNetworkAssociation, err := ec2clientvpn.NewNetworkAssociation(ctx, "example", &ec2clientvpn.NetworkAssociationArgs{
// ClientVpnEndpointId: exampleEndpoint.ID(),
// SubnetId: pulumi.Any(exampleAwsSubnet.Id),
// })
// if err != nil {
// return err
// }
// _, err = ec2clientvpn.NewRoute(ctx, "example", &ec2clientvpn.RouteArgs{
// ClientVpnEndpointId: exampleEndpoint.ID(),
// DestinationCidrBlock: pulumi.String("0.0.0.0/0"),
// TargetVpcSubnetId: exampleNetworkAssociation.SubnetId,
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// <!--End PulumiCodeChooser -->
//
// ## Import
//
// Using `pulumi import`, import AWS Client VPN routes using the endpoint ID, target subnet ID, and destination CIDR block. All values are separated by a `,`. For example:
//
// ```sh
// $ pulumi import aws:ec2clientvpn/route:Route example cvpn-endpoint-1234567890abcdef,subnet-9876543210fedcba,10.1.0.0/24
// ```
type Route struct {
pulumi.CustomResourceState
// The ID of the Client VPN endpoint.
ClientVpnEndpointId pulumi.StringOutput `pulumi:"clientVpnEndpointId"`
// A brief description of the route.
Description pulumi.StringPtrOutput `pulumi:"description"`
// The IPv4 address range, in CIDR notation, of the route destination.
DestinationCidrBlock pulumi.StringOutput `pulumi:"destinationCidrBlock"`
// Indicates how the Client VPN route was added. Will be `add-route` for routes created by this resource.
Origin pulumi.StringOutput `pulumi:"origin"`
// The ID of the Subnet to route the traffic through. It must already be attached to the Client VPN.
TargetVpcSubnetId pulumi.StringOutput `pulumi:"targetVpcSubnetId"`
// The type of the route.
Type pulumi.StringOutput `pulumi:"type"`
}
// NewRoute registers a new resource with the given unique name, arguments, and options.
func NewRoute(ctx *pulumi.Context,
name string, args *RouteArgs, opts ...pulumi.ResourceOption) (*Route, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.ClientVpnEndpointId == nil {
return nil, errors.New("invalid value for required argument 'ClientVpnEndpointId'")
}
if args.DestinationCidrBlock == nil {
return nil, errors.New("invalid value for required argument 'DestinationCidrBlock'")
}
if args.TargetVpcSubnetId == nil {
return nil, errors.New("invalid value for required argument 'TargetVpcSubnetId'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource Route
err := ctx.RegisterResource("aws:ec2clientvpn/route:Route", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetRoute gets an existing Route 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 GetRoute(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *RouteState, opts ...pulumi.ResourceOption) (*Route, error) {
var resource Route
err := ctx.ReadResource("aws:ec2clientvpn/route:Route", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Route resources.
type routeState struct {
// The ID of the Client VPN endpoint.
ClientVpnEndpointId *string `pulumi:"clientVpnEndpointId"`
// A brief description of the route.
Description *string `pulumi:"description"`
// The IPv4 address range, in CIDR notation, of the route destination.
DestinationCidrBlock *string `pulumi:"destinationCidrBlock"`
// Indicates how the Client VPN route was added. Will be `add-route` for routes created by this resource.
Origin *string `pulumi:"origin"`
// The ID of the Subnet to route the traffic through. It must already be attached to the Client VPN.
TargetVpcSubnetId *string `pulumi:"targetVpcSubnetId"`
// The type of the route.
Type *string `pulumi:"type"`
}
type RouteState struct {
// The ID of the Client VPN endpoint.
ClientVpnEndpointId pulumi.StringPtrInput
// A brief description of the route.
Description pulumi.StringPtrInput
// The IPv4 address range, in CIDR notation, of the route destination.
DestinationCidrBlock pulumi.StringPtrInput
// Indicates how the Client VPN route was added. Will be `add-route` for routes created by this resource.
Origin pulumi.StringPtrInput
// The ID of the Subnet to route the traffic through. It must already be attached to the Client VPN.
TargetVpcSubnetId pulumi.StringPtrInput
// The type of the route.
Type pulumi.StringPtrInput
}
func (RouteState) ElementType() reflect.Type {
return reflect.TypeOf((*routeState)(nil)).Elem()
}
type routeArgs struct {
// The ID of the Client VPN endpoint.
ClientVpnEndpointId string `pulumi:"clientVpnEndpointId"`
// A brief description of the route.
Description *string `pulumi:"description"`
// The IPv4 address range, in CIDR notation, of the route destination.
DestinationCidrBlock string `pulumi:"destinationCidrBlock"`
// The ID of the Subnet to route the traffic through. It must already be attached to the Client VPN.
TargetVpcSubnetId string `pulumi:"targetVpcSubnetId"`
}
// The set of arguments for constructing a Route resource.
type RouteArgs struct {
// The ID of the Client VPN endpoint.
ClientVpnEndpointId pulumi.StringInput
// A brief description of the route.
Description pulumi.StringPtrInput
// The IPv4 address range, in CIDR notation, of the route destination.
DestinationCidrBlock pulumi.StringInput
// The ID of the Subnet to route the traffic through. It must already be attached to the Client VPN.
TargetVpcSubnetId pulumi.StringInput
}
func (RouteArgs) ElementType() reflect.Type {
return reflect.TypeOf((*routeArgs)(nil)).Elem()
}
type RouteInput interface {
pulumi.Input
ToRouteOutput() RouteOutput
ToRouteOutputWithContext(ctx context.Context) RouteOutput
}
func (*Route) ElementType() reflect.Type {
return reflect.TypeOf((**Route)(nil)).Elem()
}
func (i *Route) ToRouteOutput() RouteOutput {
return i.ToRouteOutputWithContext(context.Background())
}
func (i *Route) ToRouteOutputWithContext(ctx context.Context) RouteOutput {
return pulumi.ToOutputWithContext(ctx, i).(RouteOutput)
}
// RouteArrayInput is an input type that accepts RouteArray and RouteArrayOutput values.
// You can construct a concrete instance of `RouteArrayInput` via:
//
// RouteArray{ RouteArgs{...} }
type RouteArrayInput interface {
pulumi.Input
ToRouteArrayOutput() RouteArrayOutput
ToRouteArrayOutputWithContext(context.Context) RouteArrayOutput
}
type RouteArray []RouteInput
func (RouteArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Route)(nil)).Elem()
}
func (i RouteArray) ToRouteArrayOutput() RouteArrayOutput {
return i.ToRouteArrayOutputWithContext(context.Background())
}
func (i RouteArray) ToRouteArrayOutputWithContext(ctx context.Context) RouteArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(RouteArrayOutput)
}
// RouteMapInput is an input type that accepts RouteMap and RouteMapOutput values.
// You can construct a concrete instance of `RouteMapInput` via:
//
// RouteMap{ "key": RouteArgs{...} }
type RouteMapInput interface {
pulumi.Input
ToRouteMapOutput() RouteMapOutput
ToRouteMapOutputWithContext(context.Context) RouteMapOutput
}
type RouteMap map[string]RouteInput
func (RouteMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Route)(nil)).Elem()
}
func (i RouteMap) ToRouteMapOutput() RouteMapOutput {
return i.ToRouteMapOutputWithContext(context.Background())
}
func (i RouteMap) ToRouteMapOutputWithContext(ctx context.Context) RouteMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(RouteMapOutput)
}
type RouteOutput struct{ *pulumi.OutputState }
func (RouteOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Route)(nil)).Elem()
}
func (o RouteOutput) ToRouteOutput() RouteOutput {
return o
}
func (o RouteOutput) ToRouteOutputWithContext(ctx context.Context) RouteOutput {
return o
}
// The ID of the Client VPN endpoint.
func (o RouteOutput) ClientVpnEndpointId() pulumi.StringOutput {
return o.ApplyT(func(v *Route) pulumi.StringOutput { return v.ClientVpnEndpointId }).(pulumi.StringOutput)
}
// A brief description of the route.
func (o RouteOutput) Description() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Route) pulumi.StringPtrOutput { return v.Description }).(pulumi.StringPtrOutput)
}
// The IPv4 address range, in CIDR notation, of the route destination.
func (o RouteOutput) DestinationCidrBlock() pulumi.StringOutput {
return o.ApplyT(func(v *Route) pulumi.StringOutput { return v.DestinationCidrBlock }).(pulumi.StringOutput)
}
// Indicates how the Client VPN route was added. Will be `add-route` for routes created by this resource.
func (o RouteOutput) Origin() pulumi.StringOutput {
return o.ApplyT(func(v *Route) pulumi.StringOutput { return v.Origin }).(pulumi.StringOutput)
}
// The ID of the Subnet to route the traffic through. It must already be attached to the Client VPN.
func (o RouteOutput) TargetVpcSubnetId() pulumi.StringOutput {
return o.ApplyT(func(v *Route) pulumi.StringOutput { return v.TargetVpcSubnetId }).(pulumi.StringOutput)
}
// The type of the route.
func (o RouteOutput) Type() pulumi.StringOutput {
return o.ApplyT(func(v *Route) pulumi.StringOutput { return v.Type }).(pulumi.StringOutput)
}
type RouteArrayOutput struct{ *pulumi.OutputState }
func (RouteArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Route)(nil)).Elem()
}
func (o RouteArrayOutput) ToRouteArrayOutput() RouteArrayOutput {
return o
}
func (o RouteArrayOutput) ToRouteArrayOutputWithContext(ctx context.Context) RouteArrayOutput {
return o
}
func (o RouteArrayOutput) Index(i pulumi.IntInput) RouteOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Route {
return vs[0].([]*Route)[vs[1].(int)]
}).(RouteOutput)
}
type RouteMapOutput struct{ *pulumi.OutputState }
func (RouteMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Route)(nil)).Elem()
}
func (o RouteMapOutput) ToRouteMapOutput() RouteMapOutput {
return o
}
func (o RouteMapOutput) ToRouteMapOutputWithContext(ctx context.Context) RouteMapOutput {
return o
}
func (o RouteMapOutput) MapIndex(k pulumi.StringInput) RouteOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Route {
return vs[0].(map[string]*Route)[vs[1].(string)]
}).(RouteOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*RouteInput)(nil)).Elem(), &Route{})
pulumi.RegisterInputType(reflect.TypeOf((*RouteArrayInput)(nil)).Elem(), RouteArray{})
pulumi.RegisterInputType(reflect.TypeOf((*RouteMapInput)(nil)).Elem(), RouteMap{})
pulumi.RegisterOutputType(RouteOutput{})
pulumi.RegisterOutputType(RouteArrayOutput{})
pulumi.RegisterOutputType(RouteMapOutput{})
}