forked from logicalclocks/terraform-provider-hopsworksai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresource_cluster.go
2031 lines (1907 loc) · 65.7 KB
/
resource_cluster.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
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package hopsworksai
import (
"context"
"fmt"
"regexp"
"strings"
"time"
"github.com/hashicorp/go-version"
"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/logicalclocks/terraform-provider-hopsworksai/hopsworksai/internal/api"
"github.com/logicalclocks/terraform-provider-hopsworksai/hopsworksai/internal/helpers"
"github.com/logicalclocks/terraform-provider-hopsworksai/hopsworksai/internal/structure"
)
func instanceProfileRegex() *regexp.Regexp {
return regexp.MustCompile(`^arn:aws:iam::([0-9]*):instance-profile/(.*)$`)
}
func defaultRonDBConfiguration() api.RonDBConfiguration {
ronDB := api.RonDBConfiguration{
Configuration: api.RonDBBaseConfiguration{
NdbdDefault: api.RonDBNdbdDefaultConfiguration{
ReplicationFactor: 2,
},
General: api.RonDBGeneralConfiguration{
Benchmark: api.RonDBBenchmarkConfiguration{
GrantUserPrivileges: false,
},
},
},
ManagementNodes: api.RonDBNodeConfiguration{
NodeConfiguration: api.NodeConfiguration{
DiskSize: 30,
},
Count: 1,
},
DataNodes: api.RonDBNodeConfiguration{
NodeConfiguration: api.NodeConfiguration{
DiskSize: 512,
},
Count: 2,
},
MYSQLNodes: api.MYSQLNodeConfiguration{
RonDBNodeConfiguration: api.RonDBNodeConfiguration{
NodeConfiguration: api.NodeConfiguration{
DiskSize: 128,
},
Count: 1,
},
ArrowFlightServer: false,
},
APINodes: api.RonDBNodeConfiguration{
NodeConfiguration: api.NodeConfiguration{
DiskSize: 30,
},
Count: 0,
},
}
return ronDB
}
func defaultAutoscaleConfiguration() api.AutoscaleConfigurationBase {
return api.AutoscaleConfigurationBase{
DiskSize: 512,
MinWorkers: 0,
MaxWorkers: 10,
StandbyWorkers: 0.5,
DownscaleWaitTime: 300,
}
}
func defaultSpotConfig() api.SpotConfiguration {
return api.SpotConfiguration{
MaxPrice: 100,
FallBackOnDemand: true,
}
}
func spotSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"max_price_percent": {
Description: "The maximum spot instance price in percentage of the on-demand price.",
Type: schema.TypeInt,
Optional: true,
Default: 100,
ValidateFunc: validation.IntBetween(1, 200),
},
"fall_back_on_demand": {
Description: "Fall back to on demand instance if unable to allocate a spot instance",
Type: schema.TypeBool,
Optional: true,
Default: true,
},
}
}
func clusterSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"cluster_id": {
Description: "The Id of the cluster.",
Type: schema.TypeString,
Computed: true,
},
"name": {
Description: "The name of the cluster, must be unique.",
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"version": {
Description: "The version of the cluster. For existing clusters, you can change this attribute to upgrade to a newer version of Hopsworks. If the upgrade process ended up in an error state, you can always rollback to the old version by resetting this attribute to the old version.",
Type: schema.TypeString,
Optional: true,
Default: "3.7.0",
},
"head": {
Description: "The configurations of the head node of the cluster.",
Type: schema.TypeList,
Required: true,
ForceNew: true,
MaxItems: 1,
MinItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"instance_type": {
Description: "The instance type of the head node.",
Type: schema.TypeString,
Required: true,
},
"disk_size": {
Description: "The disk size of the head node in units of GB.",
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
Default: 512,
ValidateFunc: validation.IntAtLeast(256),
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
if _, ok := d.GetOk("upgrade_in_progress"); ok && old == "0" && d.Get("state").(string) == api.Error.String() {
// This could happen only if the upgrade process failed before even starting the head node,
// so we should suppress this change to allow the user to rollback their cluster to old version
return true
}
return false
},
},
"node_id": {
Description: "The corresponding aws/azure instance id of the head node.",
Type: schema.TypeString,
Computed: true,
},
"ha_enabled": {
Description: "Use multi head node setup for high availability. This is an experimental feature that is not supported for all users and cloud providers.",
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
Default: false,
},
"private_ip": {
Description: "Private IP of the head node.",
Type: schema.TypeString,
Computed: true,
},
},
},
},
"workers": {
Description: "The configurations of worker nodes. You can add as many as you want of this block to create workers with different configurations.",
Type: schema.TypeSet,
Optional: true,
Set: helpers.WorkerSetHash,
ConflictsWith: []string{"autoscale"},
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"instance_type": {
Description: "The instance type of the worker nodes.",
Type: schema.TypeString,
Required: true,
},
"disk_size": {
Description: "The disk size of worker nodes in units of GB",
Type: schema.TypeInt,
Optional: true,
Default: 512,
ValidateFunc: validation.IntAtLeast(0),
},
"count": {
Description: "The number of worker nodes.",
Type: schema.TypeInt,
Optional: true,
Default: 1,
ValidateFunc: validation.IntAtLeast(0),
},
"spot_config": {
Description: "The configuration to use spot instances",
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
MinItems: 1,
Elem: &schema.Resource{
Schema: spotSchema(),
},
},
"private_ips": {
Description: "Array containing the private IPs of the nodes",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
},
},
},
"ssh_key": {
Description: "The ssh key name that will be attached to this cluster.",
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"backup_retention_period": {
Description: "The validity of cluster backups in days. If set to 0 cluster backups are disabled.",
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
Default: 0,
ValidateFunc: func(val interface{}, key string) (warnings []string, errors []error) {
v := val.(int)
if v != 0 && v < 7 {
errors = append(errors, fmt.Errorf("%q must be either 0 (disabled) or at least 7 days, got: %d", key, v))
}
return
},
},
"url": {
Description: "The url generated to access the cluster.",
Type: schema.TypeString,
Computed: true,
},
"tags": {
Description: "The list of custom tags to be attached to the cluster.",
Type: schema.TypeMap,
Optional: true,
ForceNew: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"issue_lets_encrypt_certificate": {
Description: "Enable or disable issuing let's encrypt certificates. This can be used to disable issuing certificates if port 80 can not be open.",
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
Default: true,
},
"attach_public_ip": {
Description: "Attach or do not attach a public ip to the cluster. This can be useful if you intend to create a cluster in a private network.",
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
Default: true,
},
"managed_users": {
Description: "Enable or disable Hopsworks.ai to manage your users.",
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
Default: true,
},
"state": {
Description: "The current state of the cluster.",
Type: schema.TypeString,
Computed: true,
},
"activation_state": {
Description: "The current activation state of the cluster.",
Type: schema.TypeString,
Computed: true,
},
"creation_date": {
Description: "The creation date of the cluster. The date is represented in RFC3339 format.",
Type: schema.TypeString,
Computed: true,
},
"start_date": {
Description: "The starting date of the cluster. The date is represented in RFC3339 format.",
Type: schema.TypeString,
Computed: true,
},
"update_state": {
Description: "The action you can use to start or stop the cluster. It has to be one of these values [none, start, stop].",
Type: schema.TypeString,
Optional: true,
Default: "none",
ValidateFunc: validation.StringInSlice([]string{"none", "start", "stop"}, false),
},
"aws_attributes": {
Description: "The configurations required to run the cluster on Amazon AWS.",
Type: schema.TypeList,
Optional: true,
ForceNew: true,
MaxItems: 1,
Elem: awsAttributesSchema(),
ExactlyOneOf: []string{"aws_attributes", "azure_attributes", "gcp_attributes"},
},
"azure_attributes": {
Description: "The configurations required to run the cluster on Microsoft Azure.",
Type: schema.TypeList,
Optional: true,
ForceNew: true,
MaxItems: 1,
Elem: azureAttributesSchema(),
ExactlyOneOf: []string{"aws_attributes", "azure_attributes", "gcp_attributes"},
},
"gcp_attributes": {
Description: "The configurations required to run the cluster on Google GCP.",
Type: schema.TypeList,
Optional: true,
ForceNew: true,
MaxItems: 1,
Elem: gcpAttributesSchema(),
ExactlyOneOf: []string{"aws_attributes", "azure_attributes", "gcp_attributes"},
},
"open_ports": {
Description: "Open the required ports to communicate with one of the Hopsworks services.",
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"feature_store": {
Description: "Open the required ports to access the feature store from outside Hopsworks.",
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"online_feature_store": {
Description: "Open the required ports to access the online feature store from outside Hopsworks.",
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"kafka": {
Description: "Open the required ports to access kafka from outside Hopsworks.",
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"ssh": {
Description: "Open the ssh port (22) to allow ssh access to your cluster.",
Type: schema.TypeBool,
Optional: true,
Default: false,
},
},
},
},
"rondb": {
Description: "Setup a cluster with managed RonDB.",
Type: schema.TypeList,
Required: true,
ForceNew: true,
MaxItems: 1,
Elem: ronDBSchema(),
},
"autoscale": {
Description: "Setup auto scaling.",
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
ConflictsWith: []string{"workers"},
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"non_gpu_workers": {
Description: "Setup auto scaling for non gpu nodes.",
Type: schema.TypeList,
Required: true,
MaxItems: 1,
Elem: autoscaleSchema(),
},
},
},
},
"init_script": {
Description: "A bash script that will run on all nodes during their initialization (must start with #!/usr/bin/env bash)",
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"run_init_script_first": {
Description: "Run the init script before any other node initialization. WARNING if your initscript interfere with the following node initialization the cluster may not start properly. Make sure that you know what you are doing.",
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
},
"os": {
Description: "The operating system to use for the instances. Supported systems are ubuntu in all regions and centos in some specific regions",
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Default: api.Ubuntu,
ValidateFunc: validation.StringInSlice([]string{api.Ubuntu.String(), api.CentOS.String()}, false),
},
"upgrade_in_progress": {
Description: "Information about ongoing cluster upgrade if any.",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"from_version": {
Description: "The version from which the cluster is upgrading.",
Type: schema.TypeString,
Computed: true,
},
"to_version": {
Description: "The version to which the cluster is upgrading.",
Type: schema.TypeString,
Computed: true,
},
},
},
},
"deactivate_hopsworksai_log_collection": {
Description: "Allow Hopsworks.ai to collect services logs to help diagnose issues with the cluster. By deactivating this option, you will not be able to get full support from our teams.",
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
Default: false,
},
"collect_logs": {
Description: "Push services' logs to AWS cloud watch.",
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
Default: false,
ConflictsWith: []string{"azure_attributes"},
},
"cluster_domain_prefix": {
Description: "Use a specific prefix in the Cluster's domain name instead of a UUID. This option is available only to users with necessary privileges.",
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"custom_hosted_zone": {
Description: "Override the default cloud.hopsworks.ai Hosted Zone. This option is available only to users with necessary privileges.",
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
}
}
func ronDBSchema() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"configuration": {
Description: "The configuration of RonDB.",
Type: schema.TypeList,
Optional: true,
Computed: true,
ForceNew: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"ndbd_default": {
Description: "The configuration of RonDB data nodes.",
Type: schema.TypeList,
Optional: true,
Computed: true,
ForceNew: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"replication_factor": {
Description: "The number of replicas created by RonDB. Set > 1 for high availability.",
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
Default: defaultRonDBConfiguration().Configuration.NdbdDefault.ReplicationFactor,
},
},
},
},
"general": {
Description: "The general configurations of RonDB.",
Type: schema.TypeList,
Optional: true,
Computed: true,
ForceNew: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"benchmark": {
Description: "The configurations required to benchmark RonDB.",
Type: schema.TypeList,
Optional: true,
Computed: true,
ForceNew: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"grant_user_privileges": {
Description: "This allow API nodes to have user privileges access to RonDB. This is needed mainly for benchmarking and for that you need API nodes.",
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
Default: defaultRonDBConfiguration().Configuration.General.Benchmark.GrantUserPrivileges,
},
},
},
},
},
},
},
},
},
ConflictsWith: []string{"rondb.0.single_node"},
},
"management_nodes": {
Description: "The configuration of RonDB management nodes.",
Type: schema.TypeList,
Optional: true,
ForceNew: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"instance_type": {
Description: "The instance type of the RonDB management node.",
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"disk_size": {
Description: "The disk size of management nodes in units of GB",
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
Default: defaultRonDBConfiguration().ManagementNodes.DiskSize,
},
"count": {
Description: "The number of management nodes.",
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
Default: defaultRonDBConfiguration().ManagementNodes.Count,
ValidateFunc: validation.IntInSlice([]int{1}),
},
"private_ips": {
Description: "Array containing the private IPs of the nodes",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
},
},
ConflictsWith: []string{"rondb.0.single_node"},
RequiredWith: []string{"rondb.0.data_nodes", "rondb.0.mysql_nodes"},
ExactlyOneOf: []string{"rondb.0.single_node"},
},
"data_nodes": {
Description: "The configuration of RonDB data nodes.",
Type: schema.TypeList,
Optional: true,
ForceNew: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"instance_type": {
Description: "The instance type of the RonDB data node.",
Type: schema.TypeString,
Required: true,
},
"disk_size": {
Description: "The disk size of data nodes in units of GB",
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
Default: defaultRonDBConfiguration().DataNodes.DiskSize,
},
"count": {
Description: "The number of data nodes. Notice that the number of RonDB data nodes have to be multiples of the replication_factor.",
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
Default: defaultRonDBConfiguration().DataNodes.Count,
},
"private_ips": {
Description: "Array containing the private IPs of the nodes",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
},
},
ConflictsWith: []string{"rondb.0.single_node"},
RequiredWith: []string{"rondb.0.management_nodes", "rondb.0.mysql_nodes"},
},
"mysql_nodes": {
Description: "The configuration of MySQL nodes.",
Type: schema.TypeList,
Optional: true,
ForceNew: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"instance_type": {
Description: "The instance type of the RonDB MySQL node.",
Type: schema.TypeString,
Required: true,
},
"disk_size": {
Description: "The disk size of MySQL nodes in units of GB",
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
Default: defaultRonDBConfiguration().MYSQLNodes.DiskSize,
},
"count": {
Description: "The number of MySQL nodes.",
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
Default: defaultRonDBConfiguration().MYSQLNodes.Count,
},
"private_ips": {
Description: "Array containing the private IPs of the nodes",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"arrow_flight_with_duckdb": {
Description: "Enable or disable ArrowFight server with DuckDB to speed up different feature store operations for external python clients.",
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
Default: defaultRonDBConfiguration().MYSQLNodes.ArrowFlightServer,
},
},
},
ConflictsWith: []string{"rondb.0.single_node"},
RequiredWith: []string{"rondb.0.management_nodes", "rondb.0.data_nodes"},
},
"api_nodes": {
Description: "The configuration of API nodes.",
Type: schema.TypeList,
Optional: true,
Computed: true,
ForceNew: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"instance_type": {
Description: "The instance type of the RonDB API node.",
Type: schema.TypeString,
Required: true,
},
"disk_size": {
Description: "The disk size of API nodes in units of GB",
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
Default: defaultRonDBConfiguration().APINodes.DiskSize,
},
"count": {
Description: "The number of API nodes.",
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
Default: defaultRonDBConfiguration().APINodes.Count,
},
"private_ips": {
Description: "Array containing the private IPs of the nodes",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
},
},
ConflictsWith: []string{"rondb.0.single_node"},
},
"single_node": {
Description: "The configuration of All in one RonDB where the management node, the data node, and the mysqld services are colocated in a single node.",
Type: schema.TypeList,
Optional: true,
ForceNew: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"instance_type": {
Description: "The instance type of the All in one RonDB node. You should use one of the supported instance types for RonDB data node.",
Type: schema.TypeString,
Required: true,
},
"disk_size": {
Description: "The disk size of data nodes in units of GB",
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
Default: defaultRonDBConfiguration().DataNodes.DiskSize,
},
"private_ips": {
Description: "Array containing the private IPs of the nodes",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
},
},
ConflictsWith: []string{"rondb.0.configuration", "rondb.0.management_nodes", "rondb.0.data_nodes", "rondb.0.mysql_nodes", "rondb.0.api_nodes"},
ExactlyOneOf: []string{"rondb.0.management_nodes"},
},
},
}
}
func autoscaleSchema() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"instance_type": {
Description: "The instance type to use while auto scaling.",
Type: schema.TypeString,
Required: true,
},
"disk_size": {
Description: "The disk size to use while auto scaling",
Type: schema.TypeInt,
Optional: true,
Default: defaultAutoscaleConfiguration().DiskSize,
},
"min_workers": {
Description: "The minimum number of workers created by auto scaling.",
Type: schema.TypeInt,
Optional: true,
Default: defaultAutoscaleConfiguration().MinWorkers,
ValidateFunc: validation.IntAtLeast(0),
},
"max_workers": {
Description: "The maximum number of workers created by auto scaling.",
Type: schema.TypeInt,
Optional: true,
Default: defaultAutoscaleConfiguration().MaxWorkers,
},
"standby_workers": {
Description: "The percentage of workers to be always available during auto scaling. If you set this value to 0 new workers will only be added when a job or a notebook requests the resources. This attribute will not be taken into account if you set the minimum number of workers to 0 and no resources are used in the cluster, instead, it will start to take effect as soon as you start using resources.",
Type: schema.TypeFloat,
Optional: true,
Default: defaultAutoscaleConfiguration().StandbyWorkers,
ValidateFunc: validation.FloatAtLeast(0),
},
"downscale_wait_time": {
Description: "The time to wait before removing unused resources.",
Type: schema.TypeInt,
Optional: true,
Default: defaultAutoscaleConfiguration().DownscaleWaitTime,
},
"spot_config": {
Description: "The configuration to use spot instances",
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
MinItems: 1,
Elem: &schema.Resource{
Schema: spotSchema(),
},
},
},
}
}
func awsAttributesSchema() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"region": {
Description: "The AWS region where the cluster will be created.",
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"bucket": {
Description: "The bucket configurations.",
Type: schema.TypeList,
Optional: true,
Computed: true,
ForceNew: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Description: "The name of the S3 bucket that the cluster will use to store data in.",
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"encryption": {
Description: "The server-side encryption configurations.",
Type: schema.TypeList,
Optional: true,
Computed: true,
ForceNew: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"mode": {
Description: "The encryption type.",
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{"None", "SSE-S3", "SSE-KMS"}, false),
},
"kms_type": {
Description: "The Key Management Service (KMS) type. This option is required for the encryption mode SSE-KMS.",
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{"User", "Managed"}, false),
},
"user_key_arn": {
Description: "The ARN of the user encryption key in KMS.",
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: validation.StringMatch(regexp.MustCompile(`^arn:aws:kms:\w+(?:-\w+)+:\d{12}:(key|alias)/(.*)$`), "invalid key arn, make sure to either use the key arn or the alias arn."),
},
"bucket_key": {
Description: "Enable or disable the usage of bucket key. Enabling this option (in case of SSE-KMS) would reduce the cost of SSE-KMS.",
Type: schema.TypeBool,
Optional: true,
Computed: true,
ForceNew: true,
},
},
},
},
"acl": {
Description: "The ACL configurations.",
Type: schema.TypeList,
Optional: true,
Computed: true,
ForceNew: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"bucket_owner_full_control": {
Description: "If ACL is enabled, allow the bucket owner to have full access control on new objects in the bucket.",
Type: schema.TypeBool,
Optional: true,
Computed: true,
ForceNew: true,
},
},
},
},
},
},
},
"instance_profile_arn": {
Description: "The ARN of the AWS instance profile that the cluster will be started with.",
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringMatch(instanceProfileRegex(), "You should use the Instance Profile ARNs"),
},
"head_instance_profile_arn": {
Description: "The ARN of the AWS instance profile that the head node will be started with.",
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: validation.StringMatch(instanceProfileRegex(), "You should use the Instance Profile ARNs"),
},
"network": {
Description: "The network configurations.",
Type: schema.TypeList,
Optional: true,
Computed: true,
ForceNew: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"vpc_id": {
Description: "The VPC id.",
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"subnet_id": {
Description: "The subnet id.",
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"security_group_id": {
Description: "The security group id.",
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
},
},
},
"eks_cluster_name": {
Description: "The name of the AWS EKS cluster.",
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: validation.StringMatch(regexp.MustCompile(`^[0-9A-Za-z][A-Za-z0-9\-_]+$`), "Invalid EKS cluster name"),
},
"ecr_registry_account_id": {
Description: "The account id used for ECR. Defaults to the user's account id, inferred from the instance profille ARN.",
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringMatch(regexp.MustCompile(`^\d{12}$`), "Invalid ECR account id"),
},
"ebs_encryption": {
Description: "The EBS disk encryption configuration.",
Type: schema.TypeList,
Optional: true,
ForceNew: true,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"kms_key": {
Description: "The KMS key to be used for encryption can be specified by its alias, ID or ARN. Leaving the KMS key unspecified results in the EC2 default encryption key being used.",
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
},
},
},
},
}
}
func azureAttributesSchema() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"location": {
Description: "The location where the cluster will be created.",
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"resource_group": {
Description: "The resource group where the cluster will be created.",
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"container": {
Description: "The container configurations.",
Type: schema.TypeList,
Optional: true,
Computed: true,
ForceNew: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"storage_account": {
Description: "The azure storage account that the cluster will use to store data in.",
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"name": {
Description: "The name of the azure storage container that the cluster will use to store data in. If not specified, it will be automatically generated.",
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
"encryption": {
Description: "The server-side encryption configurations.",
Type: schema.TypeList,
Optional: true,
Computed: true,
ForceNew: true,
MaxItems: 1,
Elem: &schema.Resource{