/
profile.go
373 lines (327 loc) · 14.5 KB
/
profile.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
// *** 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 trafficmanager
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Manages a Traffic Manager Profile to which multiple endpoints can be attached.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-azure/sdk/v4/go/azure/core"
// "github.com/pulumi/pulumi-azure/sdk/v4/go/azure/network"
// "github.com/pulumi/pulumi-random/sdk/v4/go/random"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// server, err := random.NewRandomId(ctx, "server", &random.RandomIdArgs{
// Keepers: pulumi.AnyMap{
// "azi_id": pulumi.Any(1),
// },
// ByteLength: pulumi.Int(8),
// })
// if err != nil {
// return err
// }
// exampleResourceGroup, err := core.NewResourceGroup(ctx, "exampleResourceGroup", &core.ResourceGroupArgs{
// Location: pulumi.String("West Europe"),
// })
// if err != nil {
// return err
// }
// _, err = network.NewTrafficManagerProfile(ctx, "exampleTrafficManagerProfile", &network.TrafficManagerProfileArgs{
// ResourceGroupName: exampleResourceGroup.Name,
// TrafficRoutingMethod: pulumi.String("Weighted"),
// DnsConfig: &network.TrafficManagerProfileDnsConfigArgs{
// RelativeName: server.Hex,
// Ttl: pulumi.Int(100),
// },
// MonitorConfig: &network.TrafficManagerProfileMonitorConfigArgs{
// Protocol: pulumi.String("http"),
// Port: pulumi.Int(80),
// Path: pulumi.String("/"),
// IntervalInSeconds: pulumi.Int(30),
// TimeoutInSeconds: pulumi.Int(9),
// ToleratedNumberOfFailures: pulumi.Int(3),
// },
// Tags: pulumi.StringMap{
// "environment": pulumi.String("Production"),
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// Traffic Manager Profiles can be imported using the `resource id`, e.g.
//
// ```sh
// $ pulumi import azure:trafficmanager/profile:Profile exampleProfile /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/trafficManagerProfiles/mytrafficmanagerprofile1
// ```
//
// Deprecated: azure.trafficmanager.Profile has been deprecated in favor of azure.network.TrafficManagerProfile
type Profile struct {
pulumi.CustomResourceState
// This block specifies the DNS configuration of the Profile, it supports the fields documented below.
DnsConfig ProfileDnsConfigOutput `pulumi:"dnsConfig"`
// The FQDN of the created Profile.
Fqdn pulumi.StringOutput `pulumi:"fqdn"`
// The amount of endpoints to return for DNS queries to this Profile. Possible values range from `1` to `8`.
MaxReturn pulumi.IntPtrOutput `pulumi:"maxReturn"`
// This block specifies the Endpoint monitoring configuration for the Profile, it supports the fields documented below.
MonitorConfig ProfileMonitorConfigOutput `pulumi:"monitorConfig"`
// The name of the Traffic Manager profile. Changing this forces a new resource to be created.
Name pulumi.StringOutput `pulumi:"name"`
// The status of the profile, can be set to either `Enabled` or `Disabled`. Defaults to `Enabled`.
ProfileStatus pulumi.StringOutput `pulumi:"profileStatus"`
// The name of the resource group in which to create the Traffic Manager profile.
ResourceGroupName pulumi.StringOutput `pulumi:"resourceGroupName"`
// A mapping of tags to assign to the resource.
Tags pulumi.StringMapOutput `pulumi:"tags"`
// Specifies the algorithm used to route traffic, possible values are:
TrafficRoutingMethod pulumi.StringOutput `pulumi:"trafficRoutingMethod"`
// Indicates whether Traffic View is enabled for the Traffic Manager profile.
TrafficViewEnabled pulumi.BoolPtrOutput `pulumi:"trafficViewEnabled"`
}
// NewProfile registers a new resource with the given unique name, arguments, and options.
func NewProfile(ctx *pulumi.Context,
name string, args *ProfileArgs, opts ...pulumi.ResourceOption) (*Profile, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.DnsConfig == nil {
return nil, errors.New("invalid value for required argument 'DnsConfig'")
}
if args.MonitorConfig == nil {
return nil, errors.New("invalid value for required argument 'MonitorConfig'")
}
if args.ResourceGroupName == nil {
return nil, errors.New("invalid value for required argument 'ResourceGroupName'")
}
if args.TrafficRoutingMethod == nil {
return nil, errors.New("invalid value for required argument 'TrafficRoutingMethod'")
}
var resource Profile
err := ctx.RegisterResource("azure:trafficmanager/profile:Profile", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetProfile gets an existing Profile 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 GetProfile(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *ProfileState, opts ...pulumi.ResourceOption) (*Profile, error) {
var resource Profile
err := ctx.ReadResource("azure:trafficmanager/profile:Profile", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Profile resources.
type profileState struct {
// This block specifies the DNS configuration of the Profile, it supports the fields documented below.
DnsConfig *ProfileDnsConfig `pulumi:"dnsConfig"`
// The FQDN of the created Profile.
Fqdn *string `pulumi:"fqdn"`
// The amount of endpoints to return for DNS queries to this Profile. Possible values range from `1` to `8`.
MaxReturn *int `pulumi:"maxReturn"`
// This block specifies the Endpoint monitoring configuration for the Profile, it supports the fields documented below.
MonitorConfig *ProfileMonitorConfig `pulumi:"monitorConfig"`
// The name of the Traffic Manager profile. Changing this forces a new resource to be created.
Name *string `pulumi:"name"`
// The status of the profile, can be set to either `Enabled` or `Disabled`. Defaults to `Enabled`.
ProfileStatus *string `pulumi:"profileStatus"`
// The name of the resource group in which to create the Traffic Manager profile.
ResourceGroupName *string `pulumi:"resourceGroupName"`
// A mapping of tags to assign to the resource.
Tags map[string]string `pulumi:"tags"`
// Specifies the algorithm used to route traffic, possible values are:
TrafficRoutingMethod *string `pulumi:"trafficRoutingMethod"`
// Indicates whether Traffic View is enabled for the Traffic Manager profile.
TrafficViewEnabled *bool `pulumi:"trafficViewEnabled"`
}
type ProfileState struct {
// This block specifies the DNS configuration of the Profile, it supports the fields documented below.
DnsConfig ProfileDnsConfigPtrInput
// The FQDN of the created Profile.
Fqdn pulumi.StringPtrInput
// The amount of endpoints to return for DNS queries to this Profile. Possible values range from `1` to `8`.
MaxReturn pulumi.IntPtrInput
// This block specifies the Endpoint monitoring configuration for the Profile, it supports the fields documented below.
MonitorConfig ProfileMonitorConfigPtrInput
// The name of the Traffic Manager profile. Changing this forces a new resource to be created.
Name pulumi.StringPtrInput
// The status of the profile, can be set to either `Enabled` or `Disabled`. Defaults to `Enabled`.
ProfileStatus pulumi.StringPtrInput
// The name of the resource group in which to create the Traffic Manager profile.
ResourceGroupName pulumi.StringPtrInput
// A mapping of tags to assign to the resource.
Tags pulumi.StringMapInput
// Specifies the algorithm used to route traffic, possible values are:
TrafficRoutingMethod pulumi.StringPtrInput
// Indicates whether Traffic View is enabled for the Traffic Manager profile.
TrafficViewEnabled pulumi.BoolPtrInput
}
func (ProfileState) ElementType() reflect.Type {
return reflect.TypeOf((*profileState)(nil)).Elem()
}
type profileArgs struct {
// This block specifies the DNS configuration of the Profile, it supports the fields documented below.
DnsConfig ProfileDnsConfig `pulumi:"dnsConfig"`
// The amount of endpoints to return for DNS queries to this Profile. Possible values range from `1` to `8`.
MaxReturn *int `pulumi:"maxReturn"`
// This block specifies the Endpoint monitoring configuration for the Profile, it supports the fields documented below.
MonitorConfig ProfileMonitorConfig `pulumi:"monitorConfig"`
// The name of the Traffic Manager profile. Changing this forces a new resource to be created.
Name *string `pulumi:"name"`
// The status of the profile, can be set to either `Enabled` or `Disabled`. Defaults to `Enabled`.
ProfileStatus *string `pulumi:"profileStatus"`
// The name of the resource group in which to create the Traffic Manager profile.
ResourceGroupName string `pulumi:"resourceGroupName"`
// A mapping of tags to assign to the resource.
Tags map[string]string `pulumi:"tags"`
// Specifies the algorithm used to route traffic, possible values are:
TrafficRoutingMethod string `pulumi:"trafficRoutingMethod"`
// Indicates whether Traffic View is enabled for the Traffic Manager profile.
TrafficViewEnabled *bool `pulumi:"trafficViewEnabled"`
}
// The set of arguments for constructing a Profile resource.
type ProfileArgs struct {
// This block specifies the DNS configuration of the Profile, it supports the fields documented below.
DnsConfig ProfileDnsConfigInput
// The amount of endpoints to return for DNS queries to this Profile. Possible values range from `1` to `8`.
MaxReturn pulumi.IntPtrInput
// This block specifies the Endpoint monitoring configuration for the Profile, it supports the fields documented below.
MonitorConfig ProfileMonitorConfigInput
// The name of the Traffic Manager profile. Changing this forces a new resource to be created.
Name pulumi.StringPtrInput
// The status of the profile, can be set to either `Enabled` or `Disabled`. Defaults to `Enabled`.
ProfileStatus pulumi.StringPtrInput
// The name of the resource group in which to create the Traffic Manager profile.
ResourceGroupName pulumi.StringInput
// A mapping of tags to assign to the resource.
Tags pulumi.StringMapInput
// Specifies the algorithm used to route traffic, possible values are:
TrafficRoutingMethod pulumi.StringInput
// Indicates whether Traffic View is enabled for the Traffic Manager profile.
TrafficViewEnabled pulumi.BoolPtrInput
}
func (ProfileArgs) ElementType() reflect.Type {
return reflect.TypeOf((*profileArgs)(nil)).Elem()
}
type ProfileInput interface {
pulumi.Input
ToProfileOutput() ProfileOutput
ToProfileOutputWithContext(ctx context.Context) ProfileOutput
}
func (*Profile) ElementType() reflect.Type {
return reflect.TypeOf((**Profile)(nil)).Elem()
}
func (i *Profile) ToProfileOutput() ProfileOutput {
return i.ToProfileOutputWithContext(context.Background())
}
func (i *Profile) ToProfileOutputWithContext(ctx context.Context) ProfileOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProfileOutput)
}
// ProfileArrayInput is an input type that accepts ProfileArray and ProfileArrayOutput values.
// You can construct a concrete instance of `ProfileArrayInput` via:
//
// ProfileArray{ ProfileArgs{...} }
type ProfileArrayInput interface {
pulumi.Input
ToProfileArrayOutput() ProfileArrayOutput
ToProfileArrayOutputWithContext(context.Context) ProfileArrayOutput
}
type ProfileArray []ProfileInput
func (ProfileArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Profile)(nil)).Elem()
}
func (i ProfileArray) ToProfileArrayOutput() ProfileArrayOutput {
return i.ToProfileArrayOutputWithContext(context.Background())
}
func (i ProfileArray) ToProfileArrayOutputWithContext(ctx context.Context) ProfileArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProfileArrayOutput)
}
// ProfileMapInput is an input type that accepts ProfileMap and ProfileMapOutput values.
// You can construct a concrete instance of `ProfileMapInput` via:
//
// ProfileMap{ "key": ProfileArgs{...} }
type ProfileMapInput interface {
pulumi.Input
ToProfileMapOutput() ProfileMapOutput
ToProfileMapOutputWithContext(context.Context) ProfileMapOutput
}
type ProfileMap map[string]ProfileInput
func (ProfileMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Profile)(nil)).Elem()
}
func (i ProfileMap) ToProfileMapOutput() ProfileMapOutput {
return i.ToProfileMapOutputWithContext(context.Background())
}
func (i ProfileMap) ToProfileMapOutputWithContext(ctx context.Context) ProfileMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProfileMapOutput)
}
type ProfileOutput struct{ *pulumi.OutputState }
func (ProfileOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Profile)(nil)).Elem()
}
func (o ProfileOutput) ToProfileOutput() ProfileOutput {
return o
}
func (o ProfileOutput) ToProfileOutputWithContext(ctx context.Context) ProfileOutput {
return o
}
type ProfileArrayOutput struct{ *pulumi.OutputState }
func (ProfileArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Profile)(nil)).Elem()
}
func (o ProfileArrayOutput) ToProfileArrayOutput() ProfileArrayOutput {
return o
}
func (o ProfileArrayOutput) ToProfileArrayOutputWithContext(ctx context.Context) ProfileArrayOutput {
return o
}
func (o ProfileArrayOutput) Index(i pulumi.IntInput) ProfileOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Profile {
return vs[0].([]*Profile)[vs[1].(int)]
}).(ProfileOutput)
}
type ProfileMapOutput struct{ *pulumi.OutputState }
func (ProfileMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Profile)(nil)).Elem()
}
func (o ProfileMapOutput) ToProfileMapOutput() ProfileMapOutput {
return o
}
func (o ProfileMapOutput) ToProfileMapOutputWithContext(ctx context.Context) ProfileMapOutput {
return o
}
func (o ProfileMapOutput) MapIndex(k pulumi.StringInput) ProfileOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Profile {
return vs[0].(map[string]*Profile)[vs[1].(string)]
}).(ProfileOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*ProfileInput)(nil)).Elem(), &Profile{})
pulumi.RegisterInputType(reflect.TypeOf((*ProfileArrayInput)(nil)).Elem(), ProfileArray{})
pulumi.RegisterInputType(reflect.TypeOf((*ProfileMapInput)(nil)).Elem(), ProfileMap{})
pulumi.RegisterOutputType(ProfileOutput{})
pulumi.RegisterOutputType(ProfileArrayOutput{})
pulumi.RegisterOutputType(ProfileMapOutput{})
}