/
probe.go
404 lines (349 loc) · 18.8 KB
/
probe.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
// 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 lb
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Manages a LoadBalancer Probe Resource.
//
// > **NOTE** When using this resource, the Load Balancer needs to have a FrontEnd IP Configuration Attached
//
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
// "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/lb"
// "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/network"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
// Name: pulumi.String("LoadBalancerRG"),
// Location: pulumi.String("West Europe"),
// })
// if err != nil {
// return err
// }
// examplePublicIp, err := network.NewPublicIp(ctx, "example", &network.PublicIpArgs{
// Name: pulumi.String("PublicIPForLB"),
// Location: example.Location,
// ResourceGroupName: example.Name,
// AllocationMethod: pulumi.String("Static"),
// })
// if err != nil {
// return err
// }
// exampleLoadBalancer, err := lb.NewLoadBalancer(ctx, "example", &lb.LoadBalancerArgs{
// Name: pulumi.String("TestLoadBalancer"),
// Location: example.Location,
// ResourceGroupName: example.Name,
// FrontendIpConfigurations: lb.LoadBalancerFrontendIpConfigurationArray{
// &lb.LoadBalancerFrontendIpConfigurationArgs{
// Name: pulumi.String("PublicIPAddress"),
// PublicIpAddressId: examplePublicIp.ID(),
// },
// },
// })
// if err != nil {
// return err
// }
// _, err = lb.NewProbe(ctx, "example", &lb.ProbeArgs{
// LoadbalancerId: exampleLoadBalancer.ID(),
// Name: pulumi.String("ssh-running-probe"),
// Port: pulumi.Int(22),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// Load Balancer Probes can be imported using the `resource id`, e.g.
//
// ```sh
// $ pulumi import azure:lb/probe:Probe example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Network/loadBalancers/lb1/probes/probe1
// ```
type Probe struct {
pulumi.CustomResourceState
// The interval, in seconds between probes to the backend endpoint for health status. The default value is 15, the minimum value is 5.
IntervalInSeconds pulumi.IntPtrOutput `pulumi:"intervalInSeconds"`
LoadBalancerRules pulumi.StringArrayOutput `pulumi:"loadBalancerRules"`
// The ID of the LoadBalancer in which to create the Probe. Changing this forces a new resource to be created.
LoadbalancerId pulumi.StringOutput `pulumi:"loadbalancerId"`
// Specifies the name of the Probe. Changing this forces a new resource to be created.
Name pulumi.StringOutput `pulumi:"name"`
// The number of failed probe attempts after which the backend endpoint is removed from rotation. Default to `2`. NumberOfProbes multiplied by intervalInSeconds value must be greater or equal to 10.Endpoints are returned to rotation when at least one probe is successful.
NumberOfProbes pulumi.IntPtrOutput `pulumi:"numberOfProbes"`
// Port on which the Probe queries the backend endpoint. Possible values range from 1 to 65535, inclusive.
Port pulumi.IntOutput `pulumi:"port"`
// The number of consecutive successful or failed probes that allow or deny traffic to this endpoint. Possible values range from `1` to `100`. The default value is `1`.
ProbeThreshold pulumi.IntPtrOutput `pulumi:"probeThreshold"`
// Specifies the protocol of the end point. Possible values are `Http`, `Https` or `Tcp`. If TCP is specified, a received ACK is required for the probe to be successful. If HTTP is specified, a 200 OK response from the specified URI is required for the probe to be successful. Defaults to `Tcp`.
Protocol pulumi.StringPtrOutput `pulumi:"protocol"`
// The URI used for requesting health status from the backend endpoint. Required if protocol is set to `Http` or `Https`. Otherwise, it is not allowed.
RequestPath pulumi.StringPtrOutput `pulumi:"requestPath"`
}
// NewProbe registers a new resource with the given unique name, arguments, and options.
func NewProbe(ctx *pulumi.Context,
name string, args *ProbeArgs, opts ...pulumi.ResourceOption) (*Probe, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.LoadbalancerId == nil {
return nil, errors.New("invalid value for required argument 'LoadbalancerId'")
}
if args.Port == nil {
return nil, errors.New("invalid value for required argument 'Port'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource Probe
err := ctx.RegisterResource("azure:lb/probe:Probe", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetProbe gets an existing Probe 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 GetProbe(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *ProbeState, opts ...pulumi.ResourceOption) (*Probe, error) {
var resource Probe
err := ctx.ReadResource("azure:lb/probe:Probe", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Probe resources.
type probeState struct {
// The interval, in seconds between probes to the backend endpoint for health status. The default value is 15, the minimum value is 5.
IntervalInSeconds *int `pulumi:"intervalInSeconds"`
LoadBalancerRules []string `pulumi:"loadBalancerRules"`
// The ID of the LoadBalancer in which to create the Probe. Changing this forces a new resource to be created.
LoadbalancerId *string `pulumi:"loadbalancerId"`
// Specifies the name of the Probe. Changing this forces a new resource to be created.
Name *string `pulumi:"name"`
// The number of failed probe attempts after which the backend endpoint is removed from rotation. Default to `2`. NumberOfProbes multiplied by intervalInSeconds value must be greater or equal to 10.Endpoints are returned to rotation when at least one probe is successful.
NumberOfProbes *int `pulumi:"numberOfProbes"`
// Port on which the Probe queries the backend endpoint. Possible values range from 1 to 65535, inclusive.
Port *int `pulumi:"port"`
// The number of consecutive successful or failed probes that allow or deny traffic to this endpoint. Possible values range from `1` to `100`. The default value is `1`.
ProbeThreshold *int `pulumi:"probeThreshold"`
// Specifies the protocol of the end point. Possible values are `Http`, `Https` or `Tcp`. If TCP is specified, a received ACK is required for the probe to be successful. If HTTP is specified, a 200 OK response from the specified URI is required for the probe to be successful. Defaults to `Tcp`.
Protocol *string `pulumi:"protocol"`
// The URI used for requesting health status from the backend endpoint. Required if protocol is set to `Http` or `Https`. Otherwise, it is not allowed.
RequestPath *string `pulumi:"requestPath"`
}
type ProbeState struct {
// The interval, in seconds between probes to the backend endpoint for health status. The default value is 15, the minimum value is 5.
IntervalInSeconds pulumi.IntPtrInput
LoadBalancerRules pulumi.StringArrayInput
// The ID of the LoadBalancer in which to create the Probe. Changing this forces a new resource to be created.
LoadbalancerId pulumi.StringPtrInput
// Specifies the name of the Probe. Changing this forces a new resource to be created.
Name pulumi.StringPtrInput
// The number of failed probe attempts after which the backend endpoint is removed from rotation. Default to `2`. NumberOfProbes multiplied by intervalInSeconds value must be greater or equal to 10.Endpoints are returned to rotation when at least one probe is successful.
NumberOfProbes pulumi.IntPtrInput
// Port on which the Probe queries the backend endpoint. Possible values range from 1 to 65535, inclusive.
Port pulumi.IntPtrInput
// The number of consecutive successful or failed probes that allow or deny traffic to this endpoint. Possible values range from `1` to `100`. The default value is `1`.
ProbeThreshold pulumi.IntPtrInput
// Specifies the protocol of the end point. Possible values are `Http`, `Https` or `Tcp`. If TCP is specified, a received ACK is required for the probe to be successful. If HTTP is specified, a 200 OK response from the specified URI is required for the probe to be successful. Defaults to `Tcp`.
Protocol pulumi.StringPtrInput
// The URI used for requesting health status from the backend endpoint. Required if protocol is set to `Http` or `Https`. Otherwise, it is not allowed.
RequestPath pulumi.StringPtrInput
}
func (ProbeState) ElementType() reflect.Type {
return reflect.TypeOf((*probeState)(nil)).Elem()
}
type probeArgs struct {
// The interval, in seconds between probes to the backend endpoint for health status. The default value is 15, the minimum value is 5.
IntervalInSeconds *int `pulumi:"intervalInSeconds"`
// The ID of the LoadBalancer in which to create the Probe. Changing this forces a new resource to be created.
LoadbalancerId string `pulumi:"loadbalancerId"`
// Specifies the name of the Probe. Changing this forces a new resource to be created.
Name *string `pulumi:"name"`
// The number of failed probe attempts after which the backend endpoint is removed from rotation. Default to `2`. NumberOfProbes multiplied by intervalInSeconds value must be greater or equal to 10.Endpoints are returned to rotation when at least one probe is successful.
NumberOfProbes *int `pulumi:"numberOfProbes"`
// Port on which the Probe queries the backend endpoint. Possible values range from 1 to 65535, inclusive.
Port int `pulumi:"port"`
// The number of consecutive successful or failed probes that allow or deny traffic to this endpoint. Possible values range from `1` to `100`. The default value is `1`.
ProbeThreshold *int `pulumi:"probeThreshold"`
// Specifies the protocol of the end point. Possible values are `Http`, `Https` or `Tcp`. If TCP is specified, a received ACK is required for the probe to be successful. If HTTP is specified, a 200 OK response from the specified URI is required for the probe to be successful. Defaults to `Tcp`.
Protocol *string `pulumi:"protocol"`
// The URI used for requesting health status from the backend endpoint. Required if protocol is set to `Http` or `Https`. Otherwise, it is not allowed.
RequestPath *string `pulumi:"requestPath"`
}
// The set of arguments for constructing a Probe resource.
type ProbeArgs struct {
// The interval, in seconds between probes to the backend endpoint for health status. The default value is 15, the minimum value is 5.
IntervalInSeconds pulumi.IntPtrInput
// The ID of the LoadBalancer in which to create the Probe. Changing this forces a new resource to be created.
LoadbalancerId pulumi.StringInput
// Specifies the name of the Probe. Changing this forces a new resource to be created.
Name pulumi.StringPtrInput
// The number of failed probe attempts after which the backend endpoint is removed from rotation. Default to `2`. NumberOfProbes multiplied by intervalInSeconds value must be greater or equal to 10.Endpoints are returned to rotation when at least one probe is successful.
NumberOfProbes pulumi.IntPtrInput
// Port on which the Probe queries the backend endpoint. Possible values range from 1 to 65535, inclusive.
Port pulumi.IntInput
// The number of consecutive successful or failed probes that allow or deny traffic to this endpoint. Possible values range from `1` to `100`. The default value is `1`.
ProbeThreshold pulumi.IntPtrInput
// Specifies the protocol of the end point. Possible values are `Http`, `Https` or `Tcp`. If TCP is specified, a received ACK is required for the probe to be successful. If HTTP is specified, a 200 OK response from the specified URI is required for the probe to be successful. Defaults to `Tcp`.
Protocol pulumi.StringPtrInput
// The URI used for requesting health status from the backend endpoint. Required if protocol is set to `Http` or `Https`. Otherwise, it is not allowed.
RequestPath pulumi.StringPtrInput
}
func (ProbeArgs) ElementType() reflect.Type {
return reflect.TypeOf((*probeArgs)(nil)).Elem()
}
type ProbeInput interface {
pulumi.Input
ToProbeOutput() ProbeOutput
ToProbeOutputWithContext(ctx context.Context) ProbeOutput
}
func (*Probe) ElementType() reflect.Type {
return reflect.TypeOf((**Probe)(nil)).Elem()
}
func (i *Probe) ToProbeOutput() ProbeOutput {
return i.ToProbeOutputWithContext(context.Background())
}
func (i *Probe) ToProbeOutputWithContext(ctx context.Context) ProbeOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProbeOutput)
}
// ProbeArrayInput is an input type that accepts ProbeArray and ProbeArrayOutput values.
// You can construct a concrete instance of `ProbeArrayInput` via:
//
// ProbeArray{ ProbeArgs{...} }
type ProbeArrayInput interface {
pulumi.Input
ToProbeArrayOutput() ProbeArrayOutput
ToProbeArrayOutputWithContext(context.Context) ProbeArrayOutput
}
type ProbeArray []ProbeInput
func (ProbeArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Probe)(nil)).Elem()
}
func (i ProbeArray) ToProbeArrayOutput() ProbeArrayOutput {
return i.ToProbeArrayOutputWithContext(context.Background())
}
func (i ProbeArray) ToProbeArrayOutputWithContext(ctx context.Context) ProbeArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProbeArrayOutput)
}
// ProbeMapInput is an input type that accepts ProbeMap and ProbeMapOutput values.
// You can construct a concrete instance of `ProbeMapInput` via:
//
// ProbeMap{ "key": ProbeArgs{...} }
type ProbeMapInput interface {
pulumi.Input
ToProbeMapOutput() ProbeMapOutput
ToProbeMapOutputWithContext(context.Context) ProbeMapOutput
}
type ProbeMap map[string]ProbeInput
func (ProbeMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Probe)(nil)).Elem()
}
func (i ProbeMap) ToProbeMapOutput() ProbeMapOutput {
return i.ToProbeMapOutputWithContext(context.Background())
}
func (i ProbeMap) ToProbeMapOutputWithContext(ctx context.Context) ProbeMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProbeMapOutput)
}
type ProbeOutput struct{ *pulumi.OutputState }
func (ProbeOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Probe)(nil)).Elem()
}
func (o ProbeOutput) ToProbeOutput() ProbeOutput {
return o
}
func (o ProbeOutput) ToProbeOutputWithContext(ctx context.Context) ProbeOutput {
return o
}
// The interval, in seconds between probes to the backend endpoint for health status. The default value is 15, the minimum value is 5.
func (o ProbeOutput) IntervalInSeconds() pulumi.IntPtrOutput {
return o.ApplyT(func(v *Probe) pulumi.IntPtrOutput { return v.IntervalInSeconds }).(pulumi.IntPtrOutput)
}
func (o ProbeOutput) LoadBalancerRules() pulumi.StringArrayOutput {
return o.ApplyT(func(v *Probe) pulumi.StringArrayOutput { return v.LoadBalancerRules }).(pulumi.StringArrayOutput)
}
// The ID of the LoadBalancer in which to create the Probe. Changing this forces a new resource to be created.
func (o ProbeOutput) LoadbalancerId() pulumi.StringOutput {
return o.ApplyT(func(v *Probe) pulumi.StringOutput { return v.LoadbalancerId }).(pulumi.StringOutput)
}
// Specifies the name of the Probe. Changing this forces a new resource to be created.
func (o ProbeOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *Probe) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// The number of failed probe attempts after which the backend endpoint is removed from rotation. Default to `2`. NumberOfProbes multiplied by intervalInSeconds value must be greater or equal to 10.Endpoints are returned to rotation when at least one probe is successful.
func (o ProbeOutput) NumberOfProbes() pulumi.IntPtrOutput {
return o.ApplyT(func(v *Probe) pulumi.IntPtrOutput { return v.NumberOfProbes }).(pulumi.IntPtrOutput)
}
// Port on which the Probe queries the backend endpoint. Possible values range from 1 to 65535, inclusive.
func (o ProbeOutput) Port() pulumi.IntOutput {
return o.ApplyT(func(v *Probe) pulumi.IntOutput { return v.Port }).(pulumi.IntOutput)
}
// The number of consecutive successful or failed probes that allow or deny traffic to this endpoint. Possible values range from `1` to `100`. The default value is `1`.
func (o ProbeOutput) ProbeThreshold() pulumi.IntPtrOutput {
return o.ApplyT(func(v *Probe) pulumi.IntPtrOutput { return v.ProbeThreshold }).(pulumi.IntPtrOutput)
}
// Specifies the protocol of the end point. Possible values are `Http`, `Https` or `Tcp`. If TCP is specified, a received ACK is required for the probe to be successful. If HTTP is specified, a 200 OK response from the specified URI is required for the probe to be successful. Defaults to `Tcp`.
func (o ProbeOutput) Protocol() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Probe) pulumi.StringPtrOutput { return v.Protocol }).(pulumi.StringPtrOutput)
}
// The URI used for requesting health status from the backend endpoint. Required if protocol is set to `Http` or `Https`. Otherwise, it is not allowed.
func (o ProbeOutput) RequestPath() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Probe) pulumi.StringPtrOutput { return v.RequestPath }).(pulumi.StringPtrOutput)
}
type ProbeArrayOutput struct{ *pulumi.OutputState }
func (ProbeArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Probe)(nil)).Elem()
}
func (o ProbeArrayOutput) ToProbeArrayOutput() ProbeArrayOutput {
return o
}
func (o ProbeArrayOutput) ToProbeArrayOutputWithContext(ctx context.Context) ProbeArrayOutput {
return o
}
func (o ProbeArrayOutput) Index(i pulumi.IntInput) ProbeOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Probe {
return vs[0].([]*Probe)[vs[1].(int)]
}).(ProbeOutput)
}
type ProbeMapOutput struct{ *pulumi.OutputState }
func (ProbeMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Probe)(nil)).Elem()
}
func (o ProbeMapOutput) ToProbeMapOutput() ProbeMapOutput {
return o
}
func (o ProbeMapOutput) ToProbeMapOutputWithContext(ctx context.Context) ProbeMapOutput {
return o
}
func (o ProbeMapOutput) MapIndex(k pulumi.StringInput) ProbeOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Probe {
return vs[0].(map[string]*Probe)[vs[1].(string)]
}).(ProbeOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*ProbeInput)(nil)).Elem(), &Probe{})
pulumi.RegisterInputType(reflect.TypeOf((*ProbeArrayInput)(nil)).Elem(), ProbeArray{})
pulumi.RegisterInputType(reflect.TypeOf((*ProbeMapInput)(nil)).Elem(), ProbeMap{})
pulumi.RegisterOutputType(ProbeOutput{})
pulumi.RegisterOutputType(ProbeArrayOutput{})
pulumi.RegisterOutputType(ProbeMapOutput{})
}