Skip to content

Commit 6060855

Browse files
satyakommula96anoopkverma-google
authored andcommitted
Fixes boolean fields in the ShieldedInstanceConfig struct for dataproc clusters (GoogleCloudPlatform#12671)
1 parent dd0ced8 commit 6060855

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

mmv1/third_party/terraform/services/dataproc/resource_dataproc_cluster.go

+1
Original file line numberDiff line numberDiff line change
@@ -2241,6 +2241,7 @@ func expandGceClusterConfig(d *schema.ResourceData, config *transport_tpg.Config
22412241
if v, ok := d.GetOk("cluster_config.0.gce_cluster_config.0.shielded_instance_config"); ok {
22422242
cfgSic := v.([]interface{})[0].(map[string]interface{})
22432243
conf.ShieldedInstanceConfig = &dataproc.ShieldedInstanceConfig{}
2244+
conf.ShieldedInstanceConfig.ForceSendFields = []string{"EnableIntegrityMonitoring", "EnableSecureBoot", "EnableVtpm"}
22442245
if v, ok := cfgSic["enable_integrity_monitoring"]; ok {
22452246
conf.ShieldedInstanceConfig.EnableIntegrityMonitoring = v.(bool)
22462247
}

mmv1/third_party/terraform/services/dataproc/resource_dataproc_cluster_test.go.tmpl

+44
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,31 @@ func TestAccDataprocCluster_withInternalIpOnlyTrueAndShieldedConfig(t *testing.T
254254
})
255255
}
256256

257+
func TestAccDataprocCluster_withShieldedConfig(t *testing.T) {
258+
t.Parallel()
259+
260+
var cluster dataproc.Cluster
261+
rnd := acctest.RandString(t, 10)
262+
acctest.VcrTest(t, resource.TestCase{
263+
PreCheck: func() { acctest.AccTestPreCheck(t) },
264+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
265+
CheckDestroy: testAccCheckDataprocClusterDestroy(t),
266+
Steps: []resource.TestStep{
267+
{
268+
Config: testAccDataprocCluster_withShieldedConfig(rnd),
269+
Check: resource.ComposeTestCheckFunc(
270+
testAccCheckDataprocClusterExists(t, "google_dataproc_cluster.basic", &cluster),
271+
272+
// Testing behavior for Dataproc to use only internal IP addresses
273+
resource.TestCheckResourceAttr("google_dataproc_cluster.basic", "cluster_config.0.gce_cluster_config.0.shielded_instance_config.0.enable_integrity_monitoring", "false"),
274+
resource.TestCheckResourceAttr("google_dataproc_cluster.basic", "cluster_config.0.gce_cluster_config.0.shielded_instance_config.0.enable_secure_boot", "false"),
275+
resource.TestCheckResourceAttr("google_dataproc_cluster.basic", "cluster_config.0.gce_cluster_config.0.shielded_instance_config.0.enable_vtpm", "false"),
276+
),
277+
},
278+
},
279+
})
280+
}
281+
257282
func TestAccDataprocCluster_withConfidentialCompute(t *testing.T) {
258283
t.Parallel()
259284

@@ -1581,6 +1606,25 @@ resource "google_dataproc_cluster" "basic" {
15811606
`, rnd, rnd, rnd, rnd)
15821607
}
15831608

1609+
func testAccDataprocCluster_withShieldedConfig(rnd string) string {
1610+
return fmt.Sprintf(`
1611+
resource "google_dataproc_cluster" "basic" {
1612+
name = "tf-test-dproc-%s"
1613+
region = "us-central1"
1614+
1615+
cluster_config {
1616+
gce_cluster_config {
1617+
shielded_instance_config {
1618+
enable_integrity_monitoring = false
1619+
enable_secure_boot = false
1620+
enable_vtpm = false
1621+
}
1622+
}
1623+
}
1624+
}
1625+
`, rnd)
1626+
}
1627+
15841628
func testAccDataprocCluster_withConfidentialCompute(rnd, subnetworkName string, imageUri string) string {
15851629
return fmt.Sprintf(`
15861630
resource "google_dataproc_cluster" "confidential" {

0 commit comments

Comments
 (0)