|
31 | 31 | "cluster_config.0.gce_cluster_config.0.service_account", |
32 | 32 | "cluster_config.0.gce_cluster_config.0.service_account_scopes", |
33 | 33 | "cluster_config.0.gce_cluster_config.0.internal_ip_only", |
| 34 | + "cluster_config.0.gce_cluster_config.0.shielded_instance_config", |
34 | 35 | "cluster_config.0.gce_cluster_config.0.metadata", |
35 | 36 | } |
36 | 37 |
|
| 38 | + schieldedInstanceConfigKeys = []string{ |
| 39 | + "cluster_config.0.gce_cluster_config.0.shielded_instance_config.0.enable_secure_boot", |
| 40 | + "cluster_config.0.gce_cluster_config.0.shielded_instance_config.0.enable_vtpm", |
| 41 | + "cluster_config.0.gce_cluster_config.0.shielded_instance_config.0.enable_integrity_monitoring", |
| 42 | + } |
| 43 | + |
37 | 44 | preemptibleWorkerDiskConfigKeys = []string{ |
38 | 45 | "cluster_config.0.preemptible_worker_config.0.disk_config.0.num_local_ssds", |
39 | 46 | "cluster_config.0.preemptible_worker_config.0.disk_config.0.boot_disk_size_gb", |
@@ -268,6 +275,43 @@ func resourceDataprocCluster() *schema.Resource { |
268 | 275 | ForceNew: true, |
269 | 276 | Description: `A map of the Compute Engine metadata entries to add to all instances`, |
270 | 277 | }, |
| 278 | + |
| 279 | + "shielded_instance_config": { |
| 280 | + Type: schema.TypeList, |
| 281 | + Optional: true, |
| 282 | + AtLeastOneOf: gceClusterConfigKeys, |
| 283 | + Computed: true, |
| 284 | + MaxItems: 1, |
| 285 | + Description: `Shielded Instance Config for clusters using Compute Engine Shielded VMs.`, |
| 286 | + Elem: &schema.Resource{ |
| 287 | + Schema: map[string]*schema.Schema{ |
| 288 | + "enable_secure_boot": { |
| 289 | + Type: schema.TypeBool, |
| 290 | + Optional: true, |
| 291 | + Default: false, |
| 292 | + AtLeastOneOf: schieldedInstanceConfigKeys, |
| 293 | + ForceNew: true, |
| 294 | + Description: `Defines whether instances have Secure Boot enabled.`, |
| 295 | + }, |
| 296 | + "enable_vtpm": { |
| 297 | + Type: schema.TypeBool, |
| 298 | + Optional: true, |
| 299 | + Default: false, |
| 300 | + AtLeastOneOf: schieldedInstanceConfigKeys, |
| 301 | + ForceNew: true, |
| 302 | + Description: `Defines whether instances have the vTPM enabled.`, |
| 303 | + }, |
| 304 | + "enable_integrity_monitoring": { |
| 305 | + Type: schema.TypeBool, |
| 306 | + Optional: true, |
| 307 | + Default: false, |
| 308 | + AtLeastOneOf: schieldedInstanceConfigKeys, |
| 309 | + ForceNew: true, |
| 310 | + Description: `Defines whether instances have integrity monitoring enabled.`, |
| 311 | + }, |
| 312 | + }, |
| 313 | + }, |
| 314 | + }, |
271 | 315 | }, |
272 | 316 | }, |
273 | 317 | }, |
@@ -971,6 +1015,19 @@ func expandGceClusterConfig(d *schema.ResourceData, config *Config) (*dataproc.G |
971 | 1015 | if v, ok := cfg["metadata"]; ok { |
972 | 1016 | conf.Metadata = convertStringMap(v.(map[string]interface{})) |
973 | 1017 | } |
| 1018 | + if v, ok := d.GetOk("cluster_config.0.gce_cluster_config.0.shielded_instance_config"); ok { |
| 1019 | + cfgSic := v.([]interface{})[0].(map[string]interface{}) |
| 1020 | + conf.ShieldedInstanceConfig = &dataproc.ShieldedInstanceConfig{} |
| 1021 | + if v, ok := cfgSic["enable_integrity_monitoring"]; ok { |
| 1022 | + conf.ShieldedInstanceConfig.EnableIntegrityMonitoring = v.(bool) |
| 1023 | + } |
| 1024 | + if v, ok := cfgSic["enable_secure_boot"]; ok { |
| 1025 | + conf.ShieldedInstanceConfig.EnableSecureBoot = v.(bool) |
| 1026 | + } |
| 1027 | + if v, ok := cfgSic["enable_vtpm"]; ok { |
| 1028 | + conf.ShieldedInstanceConfig.EnableVtpm = v.(bool) |
| 1029 | + } |
| 1030 | + } |
974 | 1031 | return conf, nil |
975 | 1032 | } |
976 | 1033 |
|
@@ -1354,13 +1411,13 @@ func flattenClusterConfig(d *schema.ResourceData, cfg *dataproc.ClusterConfig) ( |
1354 | 1411 | "bucket": cfg.ConfigBucket, |
1355 | 1412 | "temp_bucket": cfg.TempBucket, |
1356 | 1413 | "gce_cluster_config": flattenGceClusterConfig(d, cfg.GceClusterConfig), |
1357 | | - "security_config": flattenSecurityConfig(d, cfg.SecurityConfig), |
1358 | | - "software_config": flattenSoftwareConfig(d, cfg.SoftwareConfig), |
1359 | 1414 | "master_config": flattenInstanceGroupConfig(d, cfg.MasterConfig), |
1360 | 1415 | "worker_config": flattenInstanceGroupConfig(d, cfg.WorkerConfig), |
1361 | | - "preemptible_worker_config": flattenPreemptibleInstanceGroupConfig(d, cfg.SecondaryWorkerConfig), |
| 1416 | + "software_config": flattenSoftwareConfig(d, cfg.SoftwareConfig), |
1362 | 1417 | "encryption_config": flattenEncryptionConfig(d, cfg.EncryptionConfig), |
1363 | 1418 | "autoscaling_config": flattenAutoscalingConfig(d, cfg.AutoscalingConfig), |
| 1419 | + "security_config": flattenSecurityConfig(d, cfg.SecurityConfig), |
| 1420 | + "preemptible_worker_config": flattenPreemptibleInstanceGroupConfig(d, cfg.SecondaryWorkerConfig), |
1364 | 1421 | <% unless version == 'ga' -%> |
1365 | 1422 | "lifecycle_config": flattenLifecycleConfig(d, cfg.LifecycleConfig), |
1366 | 1423 | "endpoint_config": flattenEndpointConfig(d, cfg.EndpointConfig), |
@@ -1528,6 +1585,15 @@ func flattenGceClusterConfig(d *schema.ResourceData, gcc *dataproc.GceClusterCon |
1528 | 1585 | if len(gcc.ServiceAccountScopes) > 0 { |
1529 | 1586 | gceConfig["service_account_scopes"] = schema.NewSet(stringScopeHashcode, convertStringArrToInterface(gcc.ServiceAccountScopes)) |
1530 | 1587 | } |
| 1588 | + if gcc.ShieldedInstanceConfig != nil { |
| 1589 | + gceConfig["shielded_instance_config"] = []map[string]interface{}{ |
| 1590 | + { |
| 1591 | + "enable_integrity_monitoring": gcc.ShieldedInstanceConfig.EnableIntegrityMonitoring, |
| 1592 | + "enable_secure_boot": gcc.ShieldedInstanceConfig.EnableSecureBoot, |
| 1593 | + "enable_vtpm": gcc.ShieldedInstanceConfig.EnableVtpm, |
| 1594 | + }, |
| 1595 | + } |
| 1596 | + } |
1531 | 1597 |
|
1532 | 1598 | return []map[string]interface{}{gceConfig} |
1533 | 1599 | } |
|
0 commit comments