Skip to content

Fixes boolean fields in the ShieldedInstanceConfig struct for dataproc clusters #12671

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading