Skip to content

Commit

Permalink
Fixes boolean fields in the ShieldedInstanceConfig struct for datapro…
Browse files Browse the repository at this point in the history
  • Loading branch information
satyakommula96 authored Jan 6, 2025
1 parent 4bee7ca commit 143eb5b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2241,6 +2241,7 @@ func expandGceClusterConfig(d *schema.ResourceData, config *transport_tpg.Config
if v, ok := d.GetOk("cluster_config.0.gce_cluster_config.0.shielded_instance_config"); ok {
cfgSic := v.([]interface{})[0].(map[string]interface{})
conf.ShieldedInstanceConfig = &dataproc.ShieldedInstanceConfig{}
conf.ShieldedInstanceConfig.ForceSendFields = []string{"EnableIntegrityMonitoring", "EnableSecureBoot", "EnableVtpm"}
if v, ok := cfgSic["enable_integrity_monitoring"]; ok {
conf.ShieldedInstanceConfig.EnableIntegrityMonitoring = v.(bool)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,31 @@ func TestAccDataprocCluster_withInternalIpOnlyTrueAndShieldedConfig(t *testing.T
})
}

func TestAccDataprocCluster_withShieldedConfig(t *testing.T) {
t.Parallel()

var cluster dataproc.Cluster
rnd := acctest.RandString(t, 10)
acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckDataprocClusterDestroy(t),
Steps: []resource.TestStep{
{
Config: testAccDataprocCluster_withShieldedConfig(rnd),
Check: resource.ComposeTestCheckFunc(
testAccCheckDataprocClusterExists(t, "google_dataproc_cluster.basic", &cluster),

// Testing behavior for Dataproc to use only internal IP addresses
resource.TestCheckResourceAttr("google_dataproc_cluster.basic", "cluster_config.0.gce_cluster_config.0.shielded_instance_config.0.enable_integrity_monitoring", "false"),
resource.TestCheckResourceAttr("google_dataproc_cluster.basic", "cluster_config.0.gce_cluster_config.0.shielded_instance_config.0.enable_secure_boot", "false"),
resource.TestCheckResourceAttr("google_dataproc_cluster.basic", "cluster_config.0.gce_cluster_config.0.shielded_instance_config.0.enable_vtpm", "false"),
),
},
},
})
}

func TestAccDataprocCluster_withConfidentialCompute(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -1581,6 +1606,25 @@ resource "google_dataproc_cluster" "basic" {
`, rnd, rnd, rnd, rnd)
}

func testAccDataprocCluster_withShieldedConfig(rnd string) string {
return fmt.Sprintf(`
resource "google_dataproc_cluster" "basic" {
name = "tf-test-dproc-%s"
region = "us-central1"

cluster_config {
gce_cluster_config {
shielded_instance_config {
enable_integrity_monitoring = false
enable_secure_boot = false
enable_vtpm = false
}
}
}
}
`, rnd)
}

func testAccDataprocCluster_withConfidentialCompute(rnd, subnetworkName string, imageUri string) string {
return fmt.Sprintf(`
resource "google_dataproc_cluster" "confidential" {
Expand Down

0 comments on commit 143eb5b

Please sign in to comment.