forked from hashicorp/terraform-provider-google-beta
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathresource_dataproc_cluster.go
3378 lines (2982 loc) · 122 KB
/
resource_dataproc_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
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package dataproc
import (
"errors"
"fmt"
"log"
"regexp"
"strconv"
"strings"
"time"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource"
transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport"
"google.golang.org/api/dataproc/v1"
)
var (
resolveDataprocImageVersion = regexp.MustCompile(`(?P<Major>[^\s.-]+)\.(?P<Minor>[^\s.-]+)(?:\.(?P<Subminor>[^\s.-]+))?(?:\-(?P<Distr>[^\s.-]+))?`)
virtualClusterConfigKeys = []string{
"virtual_cluster_config.0.staging_bucket",
"virtual_cluster_config.0.auxiliary_services_config",
"virtual_cluster_config.0.kubernetes_cluster_config",
}
auxiliaryServicesConfigKeys = []string{
"virtual_cluster_config.0.auxiliary_services_config.0.metastore_config",
"virtual_cluster_config.0.auxiliary_services_config.0.spark_history_server_config",
}
auxiliaryServicesMetastoreConfigKeys = []string{
"virtual_cluster_config.0.auxiliary_services_config.0.metastore_config.0.dataproc_metastore_service",
}
auxiliaryServicesSparkHistoryServerConfigKeys = []string{
"virtual_cluster_config.0.auxiliary_services_config.0.spark_history_server_config.0.dataproc_cluster",
}
kubernetesClusterConfigKeys = []string{
"virtual_cluster_config.0.kubernetes_cluster_config.0.kubernetes_namespace",
}
gkeClusterConfigKeys = []string{
"virtual_cluster_config.0.kubernetes_cluster_config.0.gke_cluster_config.0.gke_cluster_target",
"virtual_cluster_config.0.kubernetes_cluster_config.0.gke_cluster_config.0.node_pool_target",
}
gceClusterConfigKeys = []string{
"cluster_config.0.gce_cluster_config.0.zone",
"cluster_config.0.gce_cluster_config.0.network",
"cluster_config.0.gce_cluster_config.0.subnetwork",
"cluster_config.0.gce_cluster_config.0.tags",
"cluster_config.0.gce_cluster_config.0.service_account",
"cluster_config.0.gce_cluster_config.0.service_account_scopes",
"cluster_config.0.gce_cluster_config.0.internal_ip_only",
"cluster_config.0.gce_cluster_config.0.shielded_instance_config",
"cluster_config.0.gce_cluster_config.0.metadata",
"cluster_config.0.gce_cluster_config.0.reservation_affinity",
"cluster_config.0.gce_cluster_config.0.node_group_affinity",
}
schieldedInstanceConfigKeys = []string{
"cluster_config.0.gce_cluster_config.0.shielded_instance_config.0.enable_secure_boot",
"cluster_config.0.gce_cluster_config.0.shielded_instance_config.0.enable_vtpm",
"cluster_config.0.gce_cluster_config.0.shielded_instance_config.0.enable_integrity_monitoring",
}
reservationAffinityKeys = []string{
"cluster_config.0.gce_cluster_config.0.reservation_affinity.0.consume_reservation_type",
"cluster_config.0.gce_cluster_config.0.reservation_affinity.0.key",
"cluster_config.0.gce_cluster_config.0.reservation_affinity.0.values",
}
masterDiskConfigKeys = diskConfigKeys("master_config")
workerDiskConfigKeys = diskConfigKeys("worker_config")
preemptibleWorkerDiskConfigKeys = diskConfigKeys("preemptible_worker_config")
clusterSoftwareConfigKeys = []string{
"cluster_config.0.software_config.0.image_version",
"cluster_config.0.software_config.0.override_properties",
"cluster_config.0.software_config.0.optional_components",
}
dataprocMetricConfigKeys = []string{
"cluster_config.0.dataproc_metric_config.0.metrics",
}
metricKeys = []string{
"cluster_config.0.dataproc_metric_config.0.metrics.0.metric_source",
"cluster_config.0.dataproc_metric_config.0.metrics.0.metric_overrides",
}
clusterConfigKeys = []string{
"cluster_config.0.staging_bucket",
"cluster_config.0.temp_bucket",
"cluster_config.0.gce_cluster_config",
"cluster_config.0.master_config",
"cluster_config.0.worker_config",
"cluster_config.0.preemptible_worker_config",
"cluster_config.0.security_config",
"cluster_config.0.software_config",
"cluster_config.0.initialization_action",
"cluster_config.0.encryption_config",
"cluster_config.0.autoscaling_config",
"cluster_config.0.metastore_config",
"cluster_config.0.lifecycle_config",
"cluster_config.0.endpoint_config",
"cluster_config.0.dataproc_metric_config",
"cluster_config.0.auxiliary_node_groups",
}
)
const resourceDataprocGoogleLabelPrefix = "goog-dataproc"
const resourceDataprocGoogleProvidedLabelPrefix = "labels." + resourceDataprocGoogleLabelPrefix
// The keys inside a DiskConfig. configName is the name of the field this disk
// config is inside. E.g. 'master_config', 'worker_config', or
// 'preemptible_worker_config'.
func diskConfigKeys(configName string) []string {
return []string{
"cluster_config.0." + configName + ".0.disk_config.0.num_local_ssds",
"cluster_config.0." + configName + ".0.disk_config.0.boot_disk_size_gb",
"cluster_config.0." + configName + ".0.disk_config.0.boot_disk_type",
"cluster_config.0." + configName + ".0.disk_config.0.local_ssd_interface",
}
}
// Suppress diffs for values that are equivalent except for their use of the words "location"
// compared to "region" or "zone"
func LocationDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
return LocationDiffSuppressHelper(old, new) || LocationDiffSuppressHelper(new, old)
}
func LocationDiffSuppressHelper(a, b string) bool {
return strings.Replace(a, "/locations/", "/regions/", 1) == b ||
strings.Replace(a, "/locations/", "/zones/", 1) == b
}
func resourceDataprocLabelDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
if strings.HasPrefix(k, resourceDataprocGoogleProvidedLabelPrefix) && new == "" {
return true
}
// Let diff be determined by labels (above)
if strings.HasPrefix(k, "labels.%") {
return true
}
// For other keys, don't suppress diff.
return false
}
const resourceDataprocGoogleProvidedDPGKEPrefix = "virtual_cluster_config.0.kubernetes_cluster_config.0.kubernetes_software_config.0.properties.dpgke"
const resourceDataprocGoogleProvidedSparkPrefix = "virtual_cluster_config.0.kubernetes_cluster_config.0.kubernetes_software_config.0.properties.spark"
func resourceDataprocPropertyDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
// Suppress diffs for the properties provided by API
if strings.HasPrefix(k, resourceDataprocGoogleProvidedDPGKEPrefix) && new == "" {
return true
}
if strings.HasPrefix(k, resourceDataprocGoogleProvidedSparkPrefix) && new == "" {
return true
}
// For other keys, don't suppress diff.
return false
}
func ResourceDataprocCluster() *schema.Resource {
return &schema.Resource{
Create: resourceDataprocClusterCreate,
Read: resourceDataprocClusterRead,
Update: resourceDataprocClusterUpdate,
Delete: resourceDataprocClusterDelete,
Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(45 * time.Minute),
Update: schema.DefaultTimeout(45 * time.Minute),
Delete: schema.DefaultTimeout(45 * time.Minute),
},
CustomizeDiff: customdiff.All(
tpgresource.DefaultProviderProject,
// User labels are not supported in Dataproc Virtual Cluster
tpgresource.SetLabelsDiffWithoutAttributionLabel,
),
SchemaVersion: 1,
StateUpgraders: []schema.StateUpgrader{
{
Type: resourceDataprocClusterResourceV0().CoreConfigSchema().ImpliedType(),
Upgrade: ResourceDataprocClusterStateUpgradeV0,
Version: 0,
},
},
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: `The name of the cluster, unique within the project and zone.`,
ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)
if len(value) > 55 {
errors = append(errors, fmt.Errorf(
"%q cannot be longer than 55 characters", k))
}
if !regexp.MustCompile("^[a-z0-9-]+$").MatchString(value) {
errors = append(errors, fmt.Errorf(
"%q can only contain lowercase letters, numbers and hyphens", k))
}
if !regexp.MustCompile("^[a-z]").MatchString(value) {
errors = append(errors, fmt.Errorf(
"%q must start with a letter", k))
}
if !regexp.MustCompile("[a-z0-9]$").MatchString(value) {
errors = append(errors, fmt.Errorf(
"%q must end with a number or a letter", k))
}
return
},
},
"project": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
Description: `The ID of the project in which the cluster will exist. If it is not provided, the provider project is used.`,
},
"region": {
Type: schema.TypeString,
Optional: true,
Default: "global",
ForceNew: true,
Description: `The region in which the cluster and associated nodes will be created in. Defaults to global.`,
},
"graceful_decommission_timeout": {
Type: schema.TypeString,
Optional: true,
Default: "0s",
Description: `The timeout duration which allows graceful decomissioning when you change the number of worker nodes directly through a terraform apply`,
},
"labels": {
Type: schema.TypeMap,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Description: `The list of the labels (key/value pairs) configured on the resource and to be applied to instances in the cluster.
**Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
Please refer to the field 'effective_labels' for all of the labels present on the resource.`,
},
"terraform_labels": {
Type: schema.TypeMap,
Computed: true,
Description: `The combination of labels configured directly on the resource and default labels configured on the provider.`,
Elem: &schema.Schema{Type: schema.TypeString},
},
"effective_labels": {
Type: schema.TypeMap,
Elem: &schema.Schema{Type: schema.TypeString},
Computed: true,
Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`,
},
"virtual_cluster_config": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Description: `The virtual cluster config is used when creating a Dataproc cluster that does not directly control the underlying compute resources, for example, when creating a Dataproc-on-GKE cluster. Dataproc may set default values, and values may change when clusters are updated. Exactly one of config or virtualClusterConfig must be specified.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"staging_bucket": {
Type: schema.TypeString,
Optional: true,
AtLeastOneOf: virtualClusterConfigKeys,
ForceNew: true,
Description: `A Cloud Storage bucket used to stage job dependencies, config files, and job driver console output. If you do not specify a staging bucket, Cloud Dataproc will determine a Cloud Storage location (US, ASIA, or EU) for your cluster's staging bucket according to the Compute Engine zone where your cluster is deployed, and then create and manage this project-level, per-location bucket.`,
},
"auxiliary_services_config": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
AtLeastOneOf: virtualClusterConfigKeys,
Description: `Auxiliary services configuration for a Cluster.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"metastore_config": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
AtLeastOneOf: auxiliaryServicesConfigKeys,
Description: `The Hive Metastore configuration for this workload.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"dataproc_metastore_service": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
AtLeastOneOf: auxiliaryServicesMetastoreConfigKeys,
Description: `The Hive Metastore configuration for this workload.`,
},
},
},
},
"spark_history_server_config": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
AtLeastOneOf: auxiliaryServicesConfigKeys,
Description: `The Spark History Server configuration for the workload.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"dataproc_cluster": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
AtLeastOneOf: auxiliaryServicesSparkHistoryServerConfigKeys,
Description: `Resource name of an existing Dataproc Cluster to act as a Spark History Server for the workload.`,
},
},
},
},
},
},
},
"kubernetes_cluster_config": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
AtLeastOneOf: virtualClusterConfigKeys,
Description: `The configuration for running the Dataproc cluster on Kubernetes.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"kubernetes_namespace": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
AtLeastOneOf: kubernetesClusterConfigKeys,
Description: `A namespace within the Kubernetes cluster to deploy into. If this namespace does not exist, it is created. If it exists, Dataproc verifies that another Dataproc VirtualCluster is not installed into it. If not specified, the name of the Dataproc Cluster is used.`,
},
"kubernetes_software_config": {
Type: schema.TypeList,
MaxItems: 1,
Required: true,
Description: `The software configuration for this Dataproc cluster running on Kubernetes.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"component_version": {
Type: schema.TypeMap,
Required: true,
ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString},
Description: `The components that should be installed in this Dataproc cluster. The key must be a string from the KubernetesComponent enumeration. The value is the version of the software to be installed.`,
},
"properties": {
Type: schema.TypeMap,
Optional: true,
ForceNew: true,
DiffSuppressFunc: resourceDataprocPropertyDiffSuppress,
Elem: &schema.Schema{Type: schema.TypeString},
Computed: true,
Description: `The properties to set on daemon config files. Property keys are specified in prefix:property format, for example spark:spark.kubernetes.container.image.`,
},
},
},
},
"gke_cluster_config": {
Type: schema.TypeList,
Required: true,
MaxItems: 1,
Description: `The configuration for running the Dataproc cluster on GKE.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"gke_cluster_target": {
Type: schema.TypeString,
ForceNew: true,
Optional: true,
AtLeastOneOf: gkeClusterConfigKeys,
Description: `A target GKE cluster to deploy to. It must be in the same project and region as the Dataproc cluster (the GKE cluster can be zonal or regional). Format: 'projects/{project}/locations/{location}/clusters/{cluster_id}'`,
},
"node_pool_target": {
Type: schema.TypeList,
Optional: true,
AtLeastOneOf: gkeClusterConfigKeys,
MinItems: 1,
Description: `GKE node pools where workloads will be scheduled. At least one node pool must be assigned the DEFAULT GkeNodePoolTarget.Role. If a GkeNodePoolTarget is not specified, Dataproc constructs a DEFAULT GkeNodePoolTarget.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"node_pool": {
Type: schema.TypeString,
ForceNew: true,
Required: true,
Description: `The target GKE node pool. Format: 'projects/{project}/locations/{location}/clusters/{cluster}/nodePools/{nodePool}'`,
},
"roles": {
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
ForceNew: true,
Required: true,
Description: `The roles associated with the GKE node pool.`,
},
"node_pool_config": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Description: `Input only. The configuration for the GKE node pool.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"config": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Description: `The node pool configuration.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"machine_type": {
Type: schema.TypeString,
ForceNew: true,
Optional: true,
Description: `The name of a Compute Engine machine type.`,
},
"local_ssd_count": {
Type: schema.TypeInt,
ForceNew: true,
Optional: true,
Description: `The minimum number of nodes in the node pool. Must be >= 0 and <= maxNodeCount.`,
},
"preemptible": {
Type: schema.TypeBool,
ForceNew: true,
Optional: true,
Description: `Whether the nodes are created as preemptible VM instances. Preemptible nodes cannot be used in a node pool with the CONTROLLER role or in the DEFAULT node pool if the CONTROLLER role is not assigned (the DEFAULT node pool will assume the CONTROLLER role).`,
},
"min_cpu_platform": {
Type: schema.TypeString,
ForceNew: true,
Optional: true,
Description: `Minimum CPU platform to be used by this instance. The instance may be scheduled on the specified or a newer CPU platform. Specify the friendly names of CPU platforms, such as "Intel Haswell" or "Intel Sandy Bridge".`,
},
"spot": {
Type: schema.TypeBool,
ForceNew: true,
Optional: true,
Description: `Spot flag for enabling Spot VM, which is a rebrand of the existing preemptible flag.`,
},
},
},
},
"locations": {
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
ForceNew: true,
Required: true,
Description: `The list of Compute Engine zones where node pool nodes associated with a Dataproc on GKE virtual cluster will be located.`,
},
"autoscaling": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Description: `The autoscaler configuration for this node pool. The autoscaler is enabled only when a valid configuration is present.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"min_node_count": {
Type: schema.TypeInt,
ForceNew: true,
Optional: true,
Description: `The minimum number of nodes in the node pool. Must be >= 0 and <= maxNodeCount.`,
},
"max_node_count": {
Type: schema.TypeInt,
ForceNew: true,
Optional: true,
Description: `The maximum number of nodes in the node pool. Must be >= minNodeCount, and must be > 0.`,
},
},
},
},
},
},
},
},
},
},
},
},
},
},
},
},
},
},
},
"cluster_config": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Description: `Allows you to configure various aspects of the cluster.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"staging_bucket": {
Type: schema.TypeString,
Optional: true,
AtLeastOneOf: clusterConfigKeys,
ForceNew: true,
Description: `The Cloud Storage staging bucket used to stage files, such as Hadoop jars, between client machines and the cluster. Note: If you don't explicitly specify a staging_bucket then GCP will auto create / assign one for you. However, you are not guaranteed an auto generated bucket which is solely dedicated to your cluster; it may be shared with other clusters in the same region/zone also choosing to use the auto generation option.`,
},
// If the user does not specify a staging bucket, GCP will allocate one automatically.
// The staging_bucket field provides a way for the user to supply their own
// staging bucket. The bucket field is purely a computed field which details
// the definitive bucket allocated and in use (either the user supplied one via
// staging_bucket, or the GCP generated one)
"bucket": {
Type: schema.TypeString,
Computed: true,
Description: ` The name of the cloud storage bucket ultimately used to house the staging data for the cluster. If staging_bucket is specified, it will contain this value, otherwise it will be the auto generated name.`,
},
"temp_bucket": {
Type: schema.TypeString,
Optional: true,
Computed: true,
AtLeastOneOf: clusterConfigKeys,
ForceNew: true,
Description: `The Cloud Storage temp bucket used to store ephemeral cluster and jobs data, such as Spark and MapReduce history files. Note: If you don't explicitly specify a temp_bucket then GCP will auto create / assign one for you.`,
},
"gce_cluster_config": {
Type: schema.TypeList,
Optional: true,
AtLeastOneOf: clusterConfigKeys,
Computed: true,
MaxItems: 1,
Description: `Common config settings for resources of Google Compute Engine cluster instances, applicable to all instances in the cluster.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"zone": {
Type: schema.TypeString,
Optional: true,
Computed: true,
AtLeastOneOf: gceClusterConfigKeys,
ForceNew: true,
Description: `The GCP zone where your data is stored and used (i.e. where the master and the worker nodes will be created in). If region is set to 'global' (default) then zone is mandatory, otherwise GCP is able to make use of Auto Zone Placement to determine this automatically for you. Note: This setting additionally determines and restricts which computing resources are available for use with other configs such as cluster_config.master_config.machine_type and cluster_config.worker_config.machine_type.`,
},
"network": {
Type: schema.TypeString,
Optional: true,
Computed: true,
AtLeastOneOf: gceClusterConfigKeys,
ForceNew: true,
ConflictsWith: []string{"cluster_config.0.gce_cluster_config.0.subnetwork"},
DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName,
Description: `The name or self_link of the Google Compute Engine network to the cluster will be part of. Conflicts with subnetwork. If neither is specified, this defaults to the "default" network.`,
},
"subnetwork": {
Type: schema.TypeString,
Optional: true,
AtLeastOneOf: gceClusterConfigKeys,
ForceNew: true,
ConflictsWith: []string{"cluster_config.0.gce_cluster_config.0.network"},
DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName,
Description: `The name or self_link of the Google Compute Engine subnetwork the cluster will be part of. Conflicts with network.`,
},
"tags": {
Type: schema.TypeSet,
Optional: true,
AtLeastOneOf: gceClusterConfigKeys,
ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString},
Description: `The list of instance tags applied to instances in the cluster. Tags are used to identify valid sources or targets for network firewalls.`,
},
"service_account": {
Type: schema.TypeString,
Optional: true,
AtLeastOneOf: gceClusterConfigKeys,
ForceNew: true,
Description: `The service account to be used by the Node VMs. If not specified, the "default" service account is used.`,
},
"service_account_scopes": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
AtLeastOneOf: gceClusterConfigKeys,
ForceNew: true,
Description: `The set of Google API scopes to be made available on all of the node VMs under the service_account specified. These can be either FQDNs, or scope aliases.`,
Elem: &schema.Schema{
Type: schema.TypeString,
StateFunc: func(v interface{}) string {
return tpgresource.CanonicalizeServiceScope(v.(string))
},
},
Set: tpgresource.StringScopeHashcode,
},
"internal_ip_only": {
Type: schema.TypeBool,
Optional: true,
AtLeastOneOf: gceClusterConfigKeys,
ForceNew: true,
Default: false,
Description: `By default, clusters are not restricted to internal IP addresses, and will have ephemeral external IP addresses assigned to each instance. If set to true, all instances in the cluster will only have internal IP addresses. Note: Private Google Access (also known as privateIpGoogleAccess) must be enabled on the subnetwork that the cluster will be launched in.`,
},
"metadata": {
Type: schema.TypeMap,
Optional: true,
AtLeastOneOf: gceClusterConfigKeys,
Elem: &schema.Schema{Type: schema.TypeString},
ForceNew: true,
Description: `A map of the Compute Engine metadata entries to add to all instances`,
},
"shielded_instance_config": {
Type: schema.TypeList,
Optional: true,
AtLeastOneOf: gceClusterConfigKeys,
Computed: true,
MaxItems: 1,
Description: `Shielded Instance Config for clusters using Compute Engine Shielded VMs.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enable_secure_boot": {
Type: schema.TypeBool,
Optional: true,
Default: false,
AtLeastOneOf: schieldedInstanceConfigKeys,
ForceNew: true,
Description: `Defines whether instances have Secure Boot enabled.`,
},
"enable_vtpm": {
Type: schema.TypeBool,
Optional: true,
Default: false,
AtLeastOneOf: schieldedInstanceConfigKeys,
ForceNew: true,
Description: `Defines whether instances have the vTPM enabled.`,
},
"enable_integrity_monitoring": {
Type: schema.TypeBool,
Optional: true,
Default: false,
AtLeastOneOf: schieldedInstanceConfigKeys,
ForceNew: true,
Description: `Defines whether instances have integrity monitoring enabled.`,
},
},
},
},
"reservation_affinity": {
Type: schema.TypeList,
Optional: true,
AtLeastOneOf: gceClusterConfigKeys,
Computed: true,
MaxItems: 1,
Description: `Reservation Affinity for consuming Zonal reservation.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"consume_reservation_type": {
Type: schema.TypeString,
Optional: true,
AtLeastOneOf: reservationAffinityKeys,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{"NO_RESERVATION", "ANY_RESERVATION", "SPECIFIC_RESERVATION"}, false),
Description: `Type of reservation to consume.`,
},
"key": {
Type: schema.TypeString,
Optional: true,
AtLeastOneOf: reservationAffinityKeys,
ForceNew: true,
Description: `Corresponds to the label key of reservation resource.`,
},
"values": {
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
AtLeastOneOf: reservationAffinityKeys,
ForceNew: true,
Description: `Corresponds to the label values of reservation resource.`,
},
},
},
},
"node_group_affinity": {
Type: schema.TypeList,
Optional: true,
AtLeastOneOf: gceClusterConfigKeys,
Computed: true,
MaxItems: 1,
Description: `Node Group Affinity for sole-tenant clusters.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"node_group_uri": {
Type: schema.TypeString,
ForceNew: true,
Required: true,
Description: `The URI of a sole-tenant that the cluster will be created on.`,
DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName,
},
},
},
},
},
},
},
"master_config": {
Type: schema.TypeList,
Optional: true,
AtLeastOneOf: clusterConfigKeys,
Computed: true,
MaxItems: 1,
Description: `The Compute Engine config settings for the cluster's master instance.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"num_instances": {
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
Computed: true,
Description: `Specifies the number of master nodes to create. If not specified, GCP will default to a predetermined computed value.`,
AtLeastOneOf: []string{
"cluster_config.0.master_config.0.num_instances",
"cluster_config.0.master_config.0.image_uri",
"cluster_config.0.master_config.0.machine_type",
"cluster_config.0.master_config.0.accelerators",
},
},
"image_uri": {
Type: schema.TypeString,
Optional: true,
Computed: true,
AtLeastOneOf: []string{
"cluster_config.0.master_config.0.num_instances",
"cluster_config.0.master_config.0.image_uri",
"cluster_config.0.master_config.0.machine_type",
"cluster_config.0.master_config.0.accelerators",
},
ForceNew: true,
Description: `The URI for the image to use for this master`,
},
"machine_type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
AtLeastOneOf: []string{
"cluster_config.0.master_config.0.num_instances",
"cluster_config.0.master_config.0.image_uri",
"cluster_config.0.master_config.0.machine_type",
"cluster_config.0.master_config.0.accelerators",
},
ForceNew: true,
Description: `The name of a Google Compute Engine machine type to create for the master`,
},
"min_cpu_platform": {
Type: schema.TypeString,
Optional: true,
Computed: true,
AtLeastOneOf: []string{
"cluster_config.0.master_config.0.num_instances",
"cluster_config.0.master_config.0.image_uri",
"cluster_config.0.master_config.0.machine_type",
"cluster_config.0.master_config.0.accelerators",
},
ForceNew: true,
Description: `The name of a minimum generation of CPU family for the master. If not specified, GCP will default to a predetermined computed value for each zone.`,
},
"disk_config": {
Type: schema.TypeList,
Optional: true,
Computed: true,
AtLeastOneOf: []string{
"cluster_config.0.master_config.0.num_instances",
"cluster_config.0.master_config.0.image_uri",
"cluster_config.0.master_config.0.machine_type",
"cluster_config.0.master_config.0.accelerators",
"cluster_config.0.master_config.0.disk_config",
},
MaxItems: 1,
Description: `Disk Config`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"num_local_ssds": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: `The amount of local SSD disks that will be attached to each master cluster node. Defaults to 0.`,
AtLeastOneOf: masterDiskConfigKeys,
ForceNew: true,
},
"boot_disk_size_gb": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: `Size of the primary disk attached to each node, specified in GB. The primary disk contains the boot volume and system libraries, and the smallest allowed disk size is 10GB. GCP will default to a predetermined computed value if not set (currently 500GB). Note: If SSDs are not attached, it also contains the HDFS data blocks and Hadoop working directories.`,
AtLeastOneOf: masterDiskConfigKeys,
ForceNew: true,
ValidateFunc: validation.IntAtLeast(10),
},
"boot_disk_type": {
Type: schema.TypeString,
Optional: true,
Description: `The disk type of the primary disk attached to each node. Such as "pd-ssd" or "pd-standard". Defaults to "pd-standard".`,
AtLeastOneOf: masterDiskConfigKeys,
ForceNew: true,
Default: "pd-standard",
},
"local_ssd_interface": {
Type: schema.TypeString,
Optional: true,
Description: `Interface type of local SSDs (default is "scsi"). Valid values: "scsi" (Small Computer System Interface), "nvme" (Non-Volatile Memory Express).`,
AtLeastOneOf: masterDiskConfigKeys,
ForceNew: true,
},
},
},
},
"accelerators": {
Type: schema.TypeSet,
Optional: true,
AtLeastOneOf: []string{
"cluster_config.0.master_config.0.num_instances",
"cluster_config.0.master_config.0.image_uri",
"cluster_config.0.master_config.0.machine_type",
"cluster_config.0.master_config.0.accelerators",
},
ForceNew: true,
Elem: acceleratorsSchema(),
Description: `The Compute Engine accelerator (GPU) configuration for these instances. Can be specified multiple times.`,
},
"instance_names": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
Description: `List of master instance names which have been assigned to the cluster.`,
},
},
},
},
"worker_config": {
Type: schema.TypeList,
Optional: true,
AtLeastOneOf: clusterConfigKeys,
Computed: true,
MaxItems: 1,
Description: `The Compute Engine config settings for the cluster's worker instances.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"num_instances": {
Type: schema.TypeInt,
Optional: true,
ForceNew: false,
Computed: true,
Description: `Specifies the number of worker nodes to create. If not specified, GCP will default to a predetermined computed value.`,
AtLeastOneOf: []string{
"cluster_config.0.worker_config.0.num_instances",
"cluster_config.0.worker_config.0.image_uri",
"cluster_config.0.worker_config.0.machine_type",
"cluster_config.0.worker_config.0.accelerators",
"cluster_config.0.worker_config.0.min_num_instances",
},
},
"image_uri": {
Type: schema.TypeString,
Optional: true,
Computed: true,
AtLeastOneOf: []string{
"cluster_config.0.worker_config.0.num_instances",
"cluster_config.0.worker_config.0.image_uri",
"cluster_config.0.worker_config.0.machine_type",
"cluster_config.0.worker_config.0.accelerators",
"cluster_config.0.worker_config.0.min_num_instances",
},
ForceNew: true,
Description: `The URI for the image to use for this master/worker`,
},
"machine_type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
AtLeastOneOf: []string{
"cluster_config.0.worker_config.0.num_instances",
"cluster_config.0.worker_config.0.image_uri",
"cluster_config.0.worker_config.0.machine_type",
"cluster_config.0.worker_config.0.accelerators",
"cluster_config.0.worker_config.0.min_num_instances",
},
ForceNew: true,
Description: `The name of a Google Compute Engine machine type to create for the master/worker`,
},
"min_cpu_platform": {
Type: schema.TypeString,
Optional: true,
Computed: true,
AtLeastOneOf: []string{
"cluster_config.0.worker_config.0.num_instances",
"cluster_config.0.worker_config.0.image_uri",
"cluster_config.0.worker_config.0.machine_type",
"cluster_config.0.worker_config.0.accelerators",
"cluster_config.0.worker_config.0.min_num_instances",
},
ForceNew: true,
Description: `The name of a minimum generation of CPU family for the master/worker. If not specified, GCP will default to a predetermined computed value for each zone.`,
},
"disk_config": {
Type: schema.TypeList,
Optional: true,
Computed: true,
AtLeastOneOf: []string{
"cluster_config.0.worker_config.0.num_instances",
"cluster_config.0.worker_config.0.image_uri",
"cluster_config.0.worker_config.0.machine_type",
"cluster_config.0.worker_config.0.accelerators",
"cluster_config.0.worker_config.0.min_num_instances",
"cluster_config.0.worker_config.0.disk_config",
},
MaxItems: 1,
Description: `Disk Config`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"num_local_ssds": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: `The amount of local SSD disks that will be attached to each master cluster node. Defaults to 0.`,
AtLeastOneOf: workerDiskConfigKeys,
ForceNew: true,
},
"boot_disk_size_gb": {
Type: schema.TypeInt,