/
globalClusterConfig.go
442 lines (391 loc) · 19.4 KB
/
globalClusterConfig.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
// 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 mongodbatlas
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-mongodbatlas/sdk/v3/go/mongodbatlas/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// `GlobalClusterConfig` provides a Global Cluster Configuration resource.
//
// > **NOTE:** Groups and projects are synonymous terms. You may find groupId in the official documentation.
//
// ## Examples Usage
//
// ### Example Global cluster
//
// <!--Start PulumiCodeChooser -->
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-mongodbatlas/sdk/v3/go/mongodbatlas"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// test, err := mongodbatlas.NewCluster(ctx, "test", &mongodbatlas.ClusterArgs{
// ProjectId: pulumi.String("<YOUR-PROJECT-ID>"),
// CloudBackup: pulumi.Bool(true),
// ClusterType: pulumi.String("GEOSHARDED"),
// ProviderName: pulumi.String("AWS"),
// ProviderInstanceSizeName: pulumi.String("M30"),
// ReplicationSpecs: mongodbatlas.ClusterReplicationSpecArray{
// &mongodbatlas.ClusterReplicationSpecArgs{
// ZoneName: pulumi.String("Zone 1"),
// NumShards: pulumi.Int(1),
// RegionsConfigs: mongodbatlas.ClusterReplicationSpecRegionsConfigArray{
// &mongodbatlas.ClusterReplicationSpecRegionsConfigArgs{
// RegionName: pulumi.String("EU_CENTRAL_1"),
// ElectableNodes: pulumi.Int(3),
// Priority: pulumi.Int(7),
// ReadOnlyNodes: pulumi.Int(0),
// },
// },
// },
// &mongodbatlas.ClusterReplicationSpecArgs{
// ZoneName: pulumi.String("Zone 2"),
// NumShards: pulumi.Int(1),
// RegionsConfigs: mongodbatlas.ClusterReplicationSpecRegionsConfigArray{
// &mongodbatlas.ClusterReplicationSpecRegionsConfigArgs{
// RegionName: pulumi.String("US_EAST_2"),
// ElectableNodes: pulumi.Int(3),
// Priority: pulumi.Int(7),
// ReadOnlyNodes: pulumi.Int(0),
// },
// },
// },
// },
// })
// if err != nil {
// return err
// }
// _, err = mongodbatlas.NewGlobalClusterConfig(ctx, "config", &mongodbatlas.GlobalClusterConfigArgs{
// ProjectId: test.ProjectId,
// ClusterName: test.Name,
// ManagedNamespaces: mongodbatlas.GlobalClusterConfigManagedNamespaceArray{
// &mongodbatlas.GlobalClusterConfigManagedNamespaceArgs{
// Db: pulumi.String("mydata"),
// Collection: pulumi.String("publishers"),
// CustomShardKey: pulumi.String("city"),
// IsCustomShardKeyHashed: pulumi.Bool(false),
// IsShardKeyUnique: pulumi.Bool(false),
// },
// },
// CustomZoneMappings: mongodbatlas.GlobalClusterConfigCustomZoneMappingArray{
// &mongodbatlas.GlobalClusterConfigCustomZoneMappingArgs{
// Location: pulumi.String("CA"),
// Zone: pulumi.String("Zone 1"),
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// <!--End PulumiCodeChooser -->
//
// ### Example Global cluster config
//
// <!--Start PulumiCodeChooser -->
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-mongodbatlas/sdk/v3/go/mongodbatlas"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := mongodbatlas.NewCluster(ctx, "cluster-test", &mongodbatlas.ClusterArgs{
// ProjectId: pulumi.String("<YOUR-PROJECT-ID>"),
// ClusterType: pulumi.String("REPLICASET"),
// ReplicationSpecs: mongodbatlas.ClusterReplicationSpecArray{
// &mongodbatlas.ClusterReplicationSpecArgs{
// NumShards: pulumi.Int(1),
// RegionsConfigs: mongodbatlas.ClusterReplicationSpecRegionsConfigArray{
// &mongodbatlas.ClusterReplicationSpecRegionsConfigArgs{
// RegionName: pulumi.String("US_EAST_1"),
// ElectableNodes: pulumi.Int(3),
// Priority: pulumi.Int(7),
// ReadOnlyNodes: pulumi.Int(0),
// },
// },
// },
// },
// BackupEnabled: pulumi.Bool(true),
// AutoScalingDiskGbEnabled: pulumi.Bool(true),
// MongoDbMajorVersion: pulumi.String("4.0"),
// ProviderName: pulumi.String("AWS"),
// ProviderInstanceSizeName: pulumi.String("M40"),
// })
// if err != nil {
// return err
// }
// _, err = mongodbatlas.NewGlobalClusterConfig(ctx, "config", &mongodbatlas.GlobalClusterConfigArgs{
// ProjectId: pulumi.Any(mongodbatlas_cluster.Test.Project_id),
// ClusterName: pulumi.Any(mongodbatlas_cluster.Test.Name),
// ManagedNamespaces: mongodbatlas.GlobalClusterConfigManagedNamespaceArray{
// &mongodbatlas.GlobalClusterConfigManagedNamespaceArgs{
// Db: pulumi.String("mydata"),
// Collection: pulumi.String("publishers"),
// CustomShardKey: pulumi.String("city"),
// },
// },
// CustomZoneMappings: mongodbatlas.GlobalClusterConfigCustomZoneMappingArray{
// &mongodbatlas.GlobalClusterConfigCustomZoneMappingArgs{
// Location: pulumi.String("CA"),
// Zone: pulumi.String("Zone 1"),
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// <!--End PulumiCodeChooser -->
//
// ## Import
//
// Global Clusters can be imported using project ID and cluster name, in the format `PROJECTID-CLUSTER_NAME`, e.g.
//
// ```sh
// $ pulumi import mongodbatlas:index/globalClusterConfig:GlobalClusterConfig config 1112222b3bf99403840e8934-Cluster0
// ```
// See detailed information for arguments and attributes: [MongoDB API Global Clusters](https://docs.atlas.mongodb.com/reference/api/global-clusters/)
type GlobalClusterConfig struct {
pulumi.CustomResourceState
// The name of the Global Cluster.
ClusterName pulumi.StringOutput `pulumi:"clusterName"`
// A map of all custom zone mappings defined for the Global Cluster. Atlas automatically maps each location code to the closest geographical zone. Custom zone mappings allow administrators to override these automatic mappings. If your Global Cluster does not have any custom zone mappings, this document is empty.
CustomZoneMapping pulumi.MapOutput `pulumi:"customZoneMapping"`
// Each element in the list maps one ISO location code to a zone in your Global Cluster. See Custom Zone Mapping below for more details.
CustomZoneMappings GlobalClusterConfigCustomZoneMappingArrayOutput `pulumi:"customZoneMappings"`
// Add a managed namespaces to a Global Cluster. For more information about managed namespaces, see [Global Clusters](https://docs.atlas.mongodb.com/reference/api/global-clusters/). See Managed Namespace below for more details.
ManagedNamespaces GlobalClusterConfigManagedNamespaceArrayOutput `pulumi:"managedNamespaces"`
// The unique ID for the project to create the database user.
ProjectId pulumi.StringOutput `pulumi:"projectId"`
}
// NewGlobalClusterConfig registers a new resource with the given unique name, arguments, and options.
func NewGlobalClusterConfig(ctx *pulumi.Context,
name string, args *GlobalClusterConfigArgs, opts ...pulumi.ResourceOption) (*GlobalClusterConfig, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.ClusterName == nil {
return nil, errors.New("invalid value for required argument 'ClusterName'")
}
if args.ProjectId == nil {
return nil, errors.New("invalid value for required argument 'ProjectId'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource GlobalClusterConfig
err := ctx.RegisterResource("mongodbatlas:index/globalClusterConfig:GlobalClusterConfig", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetGlobalClusterConfig gets an existing GlobalClusterConfig 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 GetGlobalClusterConfig(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *GlobalClusterConfigState, opts ...pulumi.ResourceOption) (*GlobalClusterConfig, error) {
var resource GlobalClusterConfig
err := ctx.ReadResource("mongodbatlas:index/globalClusterConfig:GlobalClusterConfig", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering GlobalClusterConfig resources.
type globalClusterConfigState struct {
// The name of the Global Cluster.
ClusterName *string `pulumi:"clusterName"`
// A map of all custom zone mappings defined for the Global Cluster. Atlas automatically maps each location code to the closest geographical zone. Custom zone mappings allow administrators to override these automatic mappings. If your Global Cluster does not have any custom zone mappings, this document is empty.
CustomZoneMapping map[string]interface{} `pulumi:"customZoneMapping"`
// Each element in the list maps one ISO location code to a zone in your Global Cluster. See Custom Zone Mapping below for more details.
CustomZoneMappings []GlobalClusterConfigCustomZoneMapping `pulumi:"customZoneMappings"`
// Add a managed namespaces to a Global Cluster. For more information about managed namespaces, see [Global Clusters](https://docs.atlas.mongodb.com/reference/api/global-clusters/). See Managed Namespace below for more details.
ManagedNamespaces []GlobalClusterConfigManagedNamespace `pulumi:"managedNamespaces"`
// The unique ID for the project to create the database user.
ProjectId *string `pulumi:"projectId"`
}
type GlobalClusterConfigState struct {
// The name of the Global Cluster.
ClusterName pulumi.StringPtrInput
// A map of all custom zone mappings defined for the Global Cluster. Atlas automatically maps each location code to the closest geographical zone. Custom zone mappings allow administrators to override these automatic mappings. If your Global Cluster does not have any custom zone mappings, this document is empty.
CustomZoneMapping pulumi.MapInput
// Each element in the list maps one ISO location code to a zone in your Global Cluster. See Custom Zone Mapping below for more details.
CustomZoneMappings GlobalClusterConfigCustomZoneMappingArrayInput
// Add a managed namespaces to a Global Cluster. For more information about managed namespaces, see [Global Clusters](https://docs.atlas.mongodb.com/reference/api/global-clusters/). See Managed Namespace below for more details.
ManagedNamespaces GlobalClusterConfigManagedNamespaceArrayInput
// The unique ID for the project to create the database user.
ProjectId pulumi.StringPtrInput
}
func (GlobalClusterConfigState) ElementType() reflect.Type {
return reflect.TypeOf((*globalClusterConfigState)(nil)).Elem()
}
type globalClusterConfigArgs struct {
// The name of the Global Cluster.
ClusterName string `pulumi:"clusterName"`
// Each element in the list maps one ISO location code to a zone in your Global Cluster. See Custom Zone Mapping below for more details.
CustomZoneMappings []GlobalClusterConfigCustomZoneMapping `pulumi:"customZoneMappings"`
// Add a managed namespaces to a Global Cluster. For more information about managed namespaces, see [Global Clusters](https://docs.atlas.mongodb.com/reference/api/global-clusters/). See Managed Namespace below for more details.
ManagedNamespaces []GlobalClusterConfigManagedNamespace `pulumi:"managedNamespaces"`
// The unique ID for the project to create the database user.
ProjectId string `pulumi:"projectId"`
}
// The set of arguments for constructing a GlobalClusterConfig resource.
type GlobalClusterConfigArgs struct {
// The name of the Global Cluster.
ClusterName pulumi.StringInput
// Each element in the list maps one ISO location code to a zone in your Global Cluster. See Custom Zone Mapping below for more details.
CustomZoneMappings GlobalClusterConfigCustomZoneMappingArrayInput
// Add a managed namespaces to a Global Cluster. For more information about managed namespaces, see [Global Clusters](https://docs.atlas.mongodb.com/reference/api/global-clusters/). See Managed Namespace below for more details.
ManagedNamespaces GlobalClusterConfigManagedNamespaceArrayInput
// The unique ID for the project to create the database user.
ProjectId pulumi.StringInput
}
func (GlobalClusterConfigArgs) ElementType() reflect.Type {
return reflect.TypeOf((*globalClusterConfigArgs)(nil)).Elem()
}
type GlobalClusterConfigInput interface {
pulumi.Input
ToGlobalClusterConfigOutput() GlobalClusterConfigOutput
ToGlobalClusterConfigOutputWithContext(ctx context.Context) GlobalClusterConfigOutput
}
func (*GlobalClusterConfig) ElementType() reflect.Type {
return reflect.TypeOf((**GlobalClusterConfig)(nil)).Elem()
}
func (i *GlobalClusterConfig) ToGlobalClusterConfigOutput() GlobalClusterConfigOutput {
return i.ToGlobalClusterConfigOutputWithContext(context.Background())
}
func (i *GlobalClusterConfig) ToGlobalClusterConfigOutputWithContext(ctx context.Context) GlobalClusterConfigOutput {
return pulumi.ToOutputWithContext(ctx, i).(GlobalClusterConfigOutput)
}
// GlobalClusterConfigArrayInput is an input type that accepts GlobalClusterConfigArray and GlobalClusterConfigArrayOutput values.
// You can construct a concrete instance of `GlobalClusterConfigArrayInput` via:
//
// GlobalClusterConfigArray{ GlobalClusterConfigArgs{...} }
type GlobalClusterConfigArrayInput interface {
pulumi.Input
ToGlobalClusterConfigArrayOutput() GlobalClusterConfigArrayOutput
ToGlobalClusterConfigArrayOutputWithContext(context.Context) GlobalClusterConfigArrayOutput
}
type GlobalClusterConfigArray []GlobalClusterConfigInput
func (GlobalClusterConfigArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*GlobalClusterConfig)(nil)).Elem()
}
func (i GlobalClusterConfigArray) ToGlobalClusterConfigArrayOutput() GlobalClusterConfigArrayOutput {
return i.ToGlobalClusterConfigArrayOutputWithContext(context.Background())
}
func (i GlobalClusterConfigArray) ToGlobalClusterConfigArrayOutputWithContext(ctx context.Context) GlobalClusterConfigArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(GlobalClusterConfigArrayOutput)
}
// GlobalClusterConfigMapInput is an input type that accepts GlobalClusterConfigMap and GlobalClusterConfigMapOutput values.
// You can construct a concrete instance of `GlobalClusterConfigMapInput` via:
//
// GlobalClusterConfigMap{ "key": GlobalClusterConfigArgs{...} }
type GlobalClusterConfigMapInput interface {
pulumi.Input
ToGlobalClusterConfigMapOutput() GlobalClusterConfigMapOutput
ToGlobalClusterConfigMapOutputWithContext(context.Context) GlobalClusterConfigMapOutput
}
type GlobalClusterConfigMap map[string]GlobalClusterConfigInput
func (GlobalClusterConfigMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*GlobalClusterConfig)(nil)).Elem()
}
func (i GlobalClusterConfigMap) ToGlobalClusterConfigMapOutput() GlobalClusterConfigMapOutput {
return i.ToGlobalClusterConfigMapOutputWithContext(context.Background())
}
func (i GlobalClusterConfigMap) ToGlobalClusterConfigMapOutputWithContext(ctx context.Context) GlobalClusterConfigMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(GlobalClusterConfigMapOutput)
}
type GlobalClusterConfigOutput struct{ *pulumi.OutputState }
func (GlobalClusterConfigOutput) ElementType() reflect.Type {
return reflect.TypeOf((**GlobalClusterConfig)(nil)).Elem()
}
func (o GlobalClusterConfigOutput) ToGlobalClusterConfigOutput() GlobalClusterConfigOutput {
return o
}
func (o GlobalClusterConfigOutput) ToGlobalClusterConfigOutputWithContext(ctx context.Context) GlobalClusterConfigOutput {
return o
}
// The name of the Global Cluster.
func (o GlobalClusterConfigOutput) ClusterName() pulumi.StringOutput {
return o.ApplyT(func(v *GlobalClusterConfig) pulumi.StringOutput { return v.ClusterName }).(pulumi.StringOutput)
}
// A map of all custom zone mappings defined for the Global Cluster. Atlas automatically maps each location code to the closest geographical zone. Custom zone mappings allow administrators to override these automatic mappings. If your Global Cluster does not have any custom zone mappings, this document is empty.
func (o GlobalClusterConfigOutput) CustomZoneMapping() pulumi.MapOutput {
return o.ApplyT(func(v *GlobalClusterConfig) pulumi.MapOutput { return v.CustomZoneMapping }).(pulumi.MapOutput)
}
// Each element in the list maps one ISO location code to a zone in your Global Cluster. See Custom Zone Mapping below for more details.
func (o GlobalClusterConfigOutput) CustomZoneMappings() GlobalClusterConfigCustomZoneMappingArrayOutput {
return o.ApplyT(func(v *GlobalClusterConfig) GlobalClusterConfigCustomZoneMappingArrayOutput {
return v.CustomZoneMappings
}).(GlobalClusterConfigCustomZoneMappingArrayOutput)
}
// Add a managed namespaces to a Global Cluster. For more information about managed namespaces, see [Global Clusters](https://docs.atlas.mongodb.com/reference/api/global-clusters/). See Managed Namespace below for more details.
func (o GlobalClusterConfigOutput) ManagedNamespaces() GlobalClusterConfigManagedNamespaceArrayOutput {
return o.ApplyT(func(v *GlobalClusterConfig) GlobalClusterConfigManagedNamespaceArrayOutput {
return v.ManagedNamespaces
}).(GlobalClusterConfigManagedNamespaceArrayOutput)
}
// The unique ID for the project to create the database user.
func (o GlobalClusterConfigOutput) ProjectId() pulumi.StringOutput {
return o.ApplyT(func(v *GlobalClusterConfig) pulumi.StringOutput { return v.ProjectId }).(pulumi.StringOutput)
}
type GlobalClusterConfigArrayOutput struct{ *pulumi.OutputState }
func (GlobalClusterConfigArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*GlobalClusterConfig)(nil)).Elem()
}
func (o GlobalClusterConfigArrayOutput) ToGlobalClusterConfigArrayOutput() GlobalClusterConfigArrayOutput {
return o
}
func (o GlobalClusterConfigArrayOutput) ToGlobalClusterConfigArrayOutputWithContext(ctx context.Context) GlobalClusterConfigArrayOutput {
return o
}
func (o GlobalClusterConfigArrayOutput) Index(i pulumi.IntInput) GlobalClusterConfigOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *GlobalClusterConfig {
return vs[0].([]*GlobalClusterConfig)[vs[1].(int)]
}).(GlobalClusterConfigOutput)
}
type GlobalClusterConfigMapOutput struct{ *pulumi.OutputState }
func (GlobalClusterConfigMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*GlobalClusterConfig)(nil)).Elem()
}
func (o GlobalClusterConfigMapOutput) ToGlobalClusterConfigMapOutput() GlobalClusterConfigMapOutput {
return o
}
func (o GlobalClusterConfigMapOutput) ToGlobalClusterConfigMapOutputWithContext(ctx context.Context) GlobalClusterConfigMapOutput {
return o
}
func (o GlobalClusterConfigMapOutput) MapIndex(k pulumi.StringInput) GlobalClusterConfigOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *GlobalClusterConfig {
return vs[0].(map[string]*GlobalClusterConfig)[vs[1].(string)]
}).(GlobalClusterConfigOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*GlobalClusterConfigInput)(nil)).Elem(), &GlobalClusterConfig{})
pulumi.RegisterInputType(reflect.TypeOf((*GlobalClusterConfigArrayInput)(nil)).Elem(), GlobalClusterConfigArray{})
pulumi.RegisterInputType(reflect.TypeOf((*GlobalClusterConfigMapInput)(nil)).Elem(), GlobalClusterConfigMap{})
pulumi.RegisterOutputType(GlobalClusterConfigOutput{})
pulumi.RegisterOutputType(GlobalClusterConfigArrayOutput{})
pulumi.RegisterOutputType(GlobalClusterConfigMapOutput{})
}