-
Notifications
You must be signed in to change notification settings - Fork 151
/
listenerRule.go
506 lines (460 loc) · 19.5 KB
/
listenerRule.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
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
// *** 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 elasticloadbalancingv2
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Provides a Load Balancer Listener Rule resource.
//
// > **Note:** `alb.ListenerRule` is known as `lb.ListenerRule`. The functionality is identical.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/cognito"
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/lb"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := lb.NewLoadBalancer(ctx, "frontEndLoadBalancer", nil)
// if err != nil {
// return err
// }
// frontEndListener, err := lb.NewListener(ctx, "frontEndListener", nil)
// if err != nil {
// return err
// }
// _, err = lb.NewListenerRule(ctx, "static", &lb.ListenerRuleArgs{
// ListenerArn: frontEndListener.Arn,
// Priority: pulumi.Int(100),
// Actions: lb.ListenerRuleActionArray{
// &lb.ListenerRuleActionArgs{
// Type: pulumi.String("forward"),
// TargetGroupArn: pulumi.Any(aws_lb_target_group.Static.Arn),
// },
// },
// Conditions: lb.ListenerRuleConditionArray{
// &lb.ListenerRuleConditionArgs{
// PathPattern: &lb.ListenerRuleConditionPathPatternArgs{
// Values: pulumi.StringArray{
// pulumi.String("/static/*"),
// },
// },
// },
// &lb.ListenerRuleConditionArgs{
// HostHeader: &lb.ListenerRuleConditionHostHeaderArgs{
// Values: pulumi.StringArray{
// pulumi.String("example.com"),
// },
// },
// },
// },
// })
// if err != nil {
// return err
// }
// _, err = lb.NewListenerRule(ctx, "hostBasedWeightedRouting", &lb.ListenerRuleArgs{
// ListenerArn: frontEndListener.Arn,
// Priority: pulumi.Int(99),
// Actions: lb.ListenerRuleActionArray{
// &lb.ListenerRuleActionArgs{
// Type: pulumi.String("forward"),
// TargetGroupArn: pulumi.Any(aws_lb_target_group.Static.Arn),
// },
// },
// Conditions: lb.ListenerRuleConditionArray{
// &lb.ListenerRuleConditionArgs{
// HostHeader: &lb.ListenerRuleConditionHostHeaderArgs{
// Values: pulumi.StringArray{
// pulumi.String("my-service.*.mycompany.io"),
// },
// },
// },
// },
// })
// if err != nil {
// return err
// }
// _, err = lb.NewListenerRule(ctx, "hostBasedRouting", &lb.ListenerRuleArgs{
// ListenerArn: frontEndListener.Arn,
// Priority: pulumi.Int(99),
// Actions: lb.ListenerRuleActionArray{
// &lb.ListenerRuleActionArgs{
// Type: pulumi.String("forward"),
// Forward: &lb.ListenerRuleActionForwardArgs{
// TargetGroups: lb.ListenerRuleActionForwardTargetGroupArray{
// &lb.ListenerRuleActionForwardTargetGroupArgs{
// Arn: pulumi.Any(aws_lb_target_group.Main.Arn),
// Weight: pulumi.Int(80),
// },
// &lb.ListenerRuleActionForwardTargetGroupArgs{
// Arn: pulumi.Any(aws_lb_target_group.Canary.Arn),
// Weight: pulumi.Int(20),
// },
// },
// Stickiness: &lb.ListenerRuleActionForwardStickinessArgs{
// Enabled: pulumi.Bool(true),
// Duration: pulumi.Int(600),
// },
// },
// },
// },
// Conditions: lb.ListenerRuleConditionArray{
// &lb.ListenerRuleConditionArgs{
// HostHeader: &lb.ListenerRuleConditionHostHeaderArgs{
// Values: pulumi.StringArray{
// pulumi.String("my-service.*.mycompany.io"),
// },
// },
// },
// },
// })
// if err != nil {
// return err
// }
// _, err = lb.NewListenerRule(ctx, "redirectHttpToHttps", &lb.ListenerRuleArgs{
// ListenerArn: frontEndListener.Arn,
// Actions: lb.ListenerRuleActionArray{
// &lb.ListenerRuleActionArgs{
// Type: pulumi.String("redirect"),
// Redirect: &lb.ListenerRuleActionRedirectArgs{
// Port: pulumi.String("443"),
// Protocol: pulumi.String("HTTPS"),
// StatusCode: pulumi.String("HTTP_301"),
// },
// },
// },
// Conditions: lb.ListenerRuleConditionArray{
// &lb.ListenerRuleConditionArgs{
// HttpHeader: &lb.ListenerRuleConditionHttpHeaderArgs{
// HttpHeaderName: pulumi.String("X-Forwarded-For"),
// Values: pulumi.StringArray{
// pulumi.String("192.168.1.*"),
// },
// },
// },
// },
// })
// if err != nil {
// return err
// }
// _, err = lb.NewListenerRule(ctx, "healthCheck", &lb.ListenerRuleArgs{
// ListenerArn: frontEndListener.Arn,
// Actions: lb.ListenerRuleActionArray{
// &lb.ListenerRuleActionArgs{
// Type: pulumi.String("fixed-response"),
// FixedResponse: &lb.ListenerRuleActionFixedResponseArgs{
// ContentType: pulumi.String("text/plain"),
// MessageBody: pulumi.String("HEALTHY"),
// StatusCode: pulumi.String("200"),
// },
// },
// },
// Conditions: lb.ListenerRuleConditionArray{
// &lb.ListenerRuleConditionArgs{
// QueryStrings: lb.ListenerRuleConditionQueryStringArray{
// &lb.ListenerRuleConditionQueryStringArgs{
// Key: pulumi.String("health"),
// Value: pulumi.String("check"),
// },
// &lb.ListenerRuleConditionQueryStringArgs{
// Value: pulumi.String("bar"),
// },
// },
// },
// },
// })
// if err != nil {
// return err
// }
// pool, err := cognito.NewUserPool(ctx, "pool", nil)
// if err != nil {
// return err
// }
// client, err := cognito.NewUserPoolClient(ctx, "client", nil)
// if err != nil {
// return err
// }
// domain, err := cognito.NewUserPoolDomain(ctx, "domain", nil)
// if err != nil {
// return err
// }
// _, err = lb.NewListenerRule(ctx, "admin", &lb.ListenerRuleArgs{
// ListenerArn: frontEndListener.Arn,
// Actions: lb.ListenerRuleActionArray{
// &lb.ListenerRuleActionArgs{
// Type: pulumi.String("authenticate-cognito"),
// AuthenticateCognito: &lb.ListenerRuleActionAuthenticateCognitoArgs{
// UserPoolArn: pool.Arn,
// UserPoolClientId: client.ID(),
// UserPoolDomain: domain.Domain,
// },
// },
// &lb.ListenerRuleActionArgs{
// Type: pulumi.String("forward"),
// TargetGroupArn: pulumi.Any(aws_lb_target_group.Static.Arn),
// },
// },
// })
// if err != nil {
// return err
// }
// _, err = lb.NewListenerRule(ctx, "oidc", &lb.ListenerRuleArgs{
// ListenerArn: frontEndListener.Arn,
// Actions: lb.ListenerRuleActionArray{
// &lb.ListenerRuleActionArgs{
// Type: pulumi.String("authenticate-oidc"),
// AuthenticateOidc: &lb.ListenerRuleActionAuthenticateOidcArgs{
// AuthorizationEndpoint: pulumi.String("https://example.com/authorization_endpoint"),
// ClientId: pulumi.String("client_id"),
// ClientSecret: pulumi.String("client_secret"),
// Issuer: pulumi.String("https://example.com"),
// TokenEndpoint: pulumi.String("https://example.com/token_endpoint"),
// UserInfoEndpoint: pulumi.String("https://example.com/user_info_endpoint"),
// },
// },
// &lb.ListenerRuleActionArgs{
// Type: pulumi.String("forward"),
// TargetGroupArn: pulumi.Any(aws_lb_target_group.Static.Arn),
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// Rules can be imported using their ARN, e.g.,
//
// ```sh
// $ pulumi import aws:elasticloadbalancingv2/listenerRule:ListenerRule front_end arn:aws:elasticloadbalancing:us-west-2:187416307283:listener-rule/app/test/8e4497da625e2d8a/9ab28ade35828f96/67b3d2d36dd7c26b
// ```
//
// Deprecated: aws.elasticloadbalancingv2.ListenerRule has been deprecated in favor of aws.lb.ListenerRule
type ListenerRule struct {
pulumi.CustomResourceState
// An Action block. Action blocks are documented below.
Actions ListenerRuleActionArrayOutput `pulumi:"actions"`
// The Amazon Resource Name (ARN) of the target group.
Arn pulumi.StringOutput `pulumi:"arn"`
// A Condition block. Multiple condition blocks of different types can be set and all must be satisfied for the rule to match. Condition blocks are documented below.
Conditions ListenerRuleConditionArrayOutput `pulumi:"conditions"`
// The ARN of the listener to which to attach the rule.
ListenerArn pulumi.StringOutput `pulumi:"listenerArn"`
// The priority for the rule between `1` and `50000`. Leaving it unset will automatically set the rule with next available priority after currently existing highest rule. A listener can't have multiple rules with the same priority.
Priority pulumi.IntOutput `pulumi:"priority"`
// 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.
Tags pulumi.StringMapOutput `pulumi:"tags"`
// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"`
}
// NewListenerRule registers a new resource with the given unique name, arguments, and options.
func NewListenerRule(ctx *pulumi.Context,
name string, args *ListenerRuleArgs, opts ...pulumi.ResourceOption) (*ListenerRule, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Actions == nil {
return nil, errors.New("invalid value for required argument 'Actions'")
}
if args.Conditions == nil {
return nil, errors.New("invalid value for required argument 'Conditions'")
}
if args.ListenerArn == nil {
return nil, errors.New("invalid value for required argument 'ListenerArn'")
}
var resource ListenerRule
err := ctx.RegisterResource("aws:elasticloadbalancingv2/listenerRule:ListenerRule", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetListenerRule gets an existing ListenerRule 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 GetListenerRule(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *ListenerRuleState, opts ...pulumi.ResourceOption) (*ListenerRule, error) {
var resource ListenerRule
err := ctx.ReadResource("aws:elasticloadbalancingv2/listenerRule:ListenerRule", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering ListenerRule resources.
type listenerRuleState struct {
// An Action block. Action blocks are documented below.
Actions []ListenerRuleAction `pulumi:"actions"`
// The Amazon Resource Name (ARN) of the target group.
Arn *string `pulumi:"arn"`
// A Condition block. Multiple condition blocks of different types can be set and all must be satisfied for the rule to match. Condition blocks are documented below.
Conditions []ListenerRuleCondition `pulumi:"conditions"`
// The ARN of the listener to which to attach the rule.
ListenerArn *string `pulumi:"listenerArn"`
// The priority for the rule between `1` and `50000`. Leaving it unset will automatically set the rule with next available priority after currently existing highest rule. A listener can't have multiple rules with the same priority.
Priority *int `pulumi:"priority"`
// 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.
Tags map[string]string `pulumi:"tags"`
// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
TagsAll map[string]string `pulumi:"tagsAll"`
}
type ListenerRuleState struct {
// An Action block. Action blocks are documented below.
Actions ListenerRuleActionArrayInput
// The Amazon Resource Name (ARN) of the target group.
Arn pulumi.StringPtrInput
// A Condition block. Multiple condition blocks of different types can be set and all must be satisfied for the rule to match. Condition blocks are documented below.
Conditions ListenerRuleConditionArrayInput
// The ARN of the listener to which to attach the rule.
ListenerArn pulumi.StringPtrInput
// The priority for the rule between `1` and `50000`. Leaving it unset will automatically set the rule with next available priority after currently existing highest rule. A listener can't have multiple rules with the same priority.
Priority pulumi.IntPtrInput
// 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.
Tags pulumi.StringMapInput
// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
TagsAll pulumi.StringMapInput
}
func (ListenerRuleState) ElementType() reflect.Type {
return reflect.TypeOf((*listenerRuleState)(nil)).Elem()
}
type listenerRuleArgs struct {
// An Action block. Action blocks are documented below.
Actions []ListenerRuleAction `pulumi:"actions"`
// A Condition block. Multiple condition blocks of different types can be set and all must be satisfied for the rule to match. Condition blocks are documented below.
Conditions []ListenerRuleCondition `pulumi:"conditions"`
// The ARN of the listener to which to attach the rule.
ListenerArn string `pulumi:"listenerArn"`
// The priority for the rule between `1` and `50000`. Leaving it unset will automatically set the rule with next available priority after currently existing highest rule. A listener can't have multiple rules with the same priority.
Priority *int `pulumi:"priority"`
// 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.
Tags map[string]string `pulumi:"tags"`
}
// The set of arguments for constructing a ListenerRule resource.
type ListenerRuleArgs struct {
// An Action block. Action blocks are documented below.
Actions ListenerRuleActionArrayInput
// A Condition block. Multiple condition blocks of different types can be set and all must be satisfied for the rule to match. Condition blocks are documented below.
Conditions ListenerRuleConditionArrayInput
// The ARN of the listener to which to attach the rule.
ListenerArn pulumi.StringInput
// The priority for the rule between `1` and `50000`. Leaving it unset will automatically set the rule with next available priority after currently existing highest rule. A listener can't have multiple rules with the same priority.
Priority pulumi.IntPtrInput
// 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.
Tags pulumi.StringMapInput
}
func (ListenerRuleArgs) ElementType() reflect.Type {
return reflect.TypeOf((*listenerRuleArgs)(nil)).Elem()
}
type ListenerRuleInput interface {
pulumi.Input
ToListenerRuleOutput() ListenerRuleOutput
ToListenerRuleOutputWithContext(ctx context.Context) ListenerRuleOutput
}
func (*ListenerRule) ElementType() reflect.Type {
return reflect.TypeOf((**ListenerRule)(nil)).Elem()
}
func (i *ListenerRule) ToListenerRuleOutput() ListenerRuleOutput {
return i.ToListenerRuleOutputWithContext(context.Background())
}
func (i *ListenerRule) ToListenerRuleOutputWithContext(ctx context.Context) ListenerRuleOutput {
return pulumi.ToOutputWithContext(ctx, i).(ListenerRuleOutput)
}
// ListenerRuleArrayInput is an input type that accepts ListenerRuleArray and ListenerRuleArrayOutput values.
// You can construct a concrete instance of `ListenerRuleArrayInput` via:
//
// ListenerRuleArray{ ListenerRuleArgs{...} }
type ListenerRuleArrayInput interface {
pulumi.Input
ToListenerRuleArrayOutput() ListenerRuleArrayOutput
ToListenerRuleArrayOutputWithContext(context.Context) ListenerRuleArrayOutput
}
type ListenerRuleArray []ListenerRuleInput
func (ListenerRuleArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*ListenerRule)(nil)).Elem()
}
func (i ListenerRuleArray) ToListenerRuleArrayOutput() ListenerRuleArrayOutput {
return i.ToListenerRuleArrayOutputWithContext(context.Background())
}
func (i ListenerRuleArray) ToListenerRuleArrayOutputWithContext(ctx context.Context) ListenerRuleArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(ListenerRuleArrayOutput)
}
// ListenerRuleMapInput is an input type that accepts ListenerRuleMap and ListenerRuleMapOutput values.
// You can construct a concrete instance of `ListenerRuleMapInput` via:
//
// ListenerRuleMap{ "key": ListenerRuleArgs{...} }
type ListenerRuleMapInput interface {
pulumi.Input
ToListenerRuleMapOutput() ListenerRuleMapOutput
ToListenerRuleMapOutputWithContext(context.Context) ListenerRuleMapOutput
}
type ListenerRuleMap map[string]ListenerRuleInput
func (ListenerRuleMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*ListenerRule)(nil)).Elem()
}
func (i ListenerRuleMap) ToListenerRuleMapOutput() ListenerRuleMapOutput {
return i.ToListenerRuleMapOutputWithContext(context.Background())
}
func (i ListenerRuleMap) ToListenerRuleMapOutputWithContext(ctx context.Context) ListenerRuleMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(ListenerRuleMapOutput)
}
type ListenerRuleOutput struct{ *pulumi.OutputState }
func (ListenerRuleOutput) ElementType() reflect.Type {
return reflect.TypeOf((**ListenerRule)(nil)).Elem()
}
func (o ListenerRuleOutput) ToListenerRuleOutput() ListenerRuleOutput {
return o
}
func (o ListenerRuleOutput) ToListenerRuleOutputWithContext(ctx context.Context) ListenerRuleOutput {
return o
}
type ListenerRuleArrayOutput struct{ *pulumi.OutputState }
func (ListenerRuleArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*ListenerRule)(nil)).Elem()
}
func (o ListenerRuleArrayOutput) ToListenerRuleArrayOutput() ListenerRuleArrayOutput {
return o
}
func (o ListenerRuleArrayOutput) ToListenerRuleArrayOutputWithContext(ctx context.Context) ListenerRuleArrayOutput {
return o
}
func (o ListenerRuleArrayOutput) Index(i pulumi.IntInput) ListenerRuleOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *ListenerRule {
return vs[0].([]*ListenerRule)[vs[1].(int)]
}).(ListenerRuleOutput)
}
type ListenerRuleMapOutput struct{ *pulumi.OutputState }
func (ListenerRuleMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*ListenerRule)(nil)).Elem()
}
func (o ListenerRuleMapOutput) ToListenerRuleMapOutput() ListenerRuleMapOutput {
return o
}
func (o ListenerRuleMapOutput) ToListenerRuleMapOutputWithContext(ctx context.Context) ListenerRuleMapOutput {
return o
}
func (o ListenerRuleMapOutput) MapIndex(k pulumi.StringInput) ListenerRuleOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *ListenerRule {
return vs[0].(map[string]*ListenerRule)[vs[1].(string)]
}).(ListenerRuleOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*ListenerRuleInput)(nil)).Elem(), &ListenerRule{})
pulumi.RegisterInputType(reflect.TypeOf((*ListenerRuleArrayInput)(nil)).Elem(), ListenerRuleArray{})
pulumi.RegisterInputType(reflect.TypeOf((*ListenerRuleMapInput)(nil)).Elem(), ListenerRuleMap{})
pulumi.RegisterOutputType(ListenerRuleOutput{})
pulumi.RegisterOutputType(ListenerRuleArrayOutput{})
pulumi.RegisterOutputType(ListenerRuleMapOutput{})
}