-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding in enable_confidential_compute for boot_disk (#9280)
- Loading branch information
Showing
2 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1785,6 +1785,48 @@ func TestAccComputeInstanceConfidentialInstanceConfigMain(t *testing.T) { | |
}) | ||
} | ||
|
||
|
||
<% unless version == 'ga' -%> | ||
func TestAccComputeInstance_confidentialHyperDiskBootDisk(t *testing.T) { | ||
t.Parallel() | ||
kms := acctest.BootstrapKMSKeyWithPurposeInLocationAndName(t, "ENCRYPT_DECRYPT", "us-central1", "tf-bootstrap-hyperdisk-key1") | ||
|
||
context_1 := map[string]interface{}{ | ||
"instance_name": fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10)), | ||
"confidential_compute": true, | ||
"key_ring": kms.KeyRing.Name, | ||
"key_name": kms.CryptoKey.Name, | ||
"zone": "us-central1-a", | ||
|
||
} | ||
|
||
context_2 := map[string]interface{}{ | ||
"instance_name": context_1["instance_name"], | ||
"confidential_compute": false, | ||
"key_ring" : context_1["key_ring"], | ||
"key_name": context_1["key_name"], | ||
"zone": context_1["zone"], | ||
} | ||
|
||
|
||
acctest.VcrTest(t, resource.TestCase{ | ||
PreCheck: func() { acctest.AccTestPreCheck(t) }, | ||
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), | ||
CheckDestroy: testAccCheckComputeInstanceDestroyProducer(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccComputeInstanceConfidentialHyperDiskBootDisk(context_1), | ||
}, | ||
computeInstanceImportStep(context_1["zone"].(string), context_1["instance_name"].(string), []string{"allow_stopping_for_update"}), | ||
{ | ||
Config: testAccComputeInstanceConfidentialHyperDiskBootDisk(context_2), | ||
}, | ||
computeInstanceImportStep(context_2["zone"].(string), context_2["instance_name"].(string), []string{"allow_stopping_for_update"}), | ||
}, | ||
}) | ||
} | ||
<% end -%> | ||
|
||
func TestAccComputeInstance_enableDisplay(t *testing.T) { | ||
t.Parallel() | ||
|
||
|
@@ -6850,6 +6892,50 @@ resource "google_compute_instance" "foobar" { | |
`, instance, enableConfidentialCompute) | ||
} | ||
|
||
<% unless version == 'ga' -%> | ||
func testAccComputeInstanceConfidentialHyperDiskBootDisk(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
data "google_compute_image" "my_image" { | ||
family = "ubuntu-2204-lts" | ||
project = "ubuntu-os-cloud" | ||
} | ||
|
||
data "google_project" "project" {} | ||
|
||
resource "google_kms_crypto_key_iam_binding" "crypto_key" { | ||
crypto_key_id = "%{key_name}" | ||
role = "roles/cloudkms.cryptoKeyEncrypterDecrypter" | ||
members = [ | ||
"serviceAccount:${data.google_project.project.number}[email protected]", | ||
] | ||
} | ||
|
||
resource "google_compute_instance" "foobar" { | ||
name = "%{instance_name}" | ||
machine_type = "n2-standard-2" | ||
zone = "%{zone}" | ||
|
||
boot_disk { | ||
|
||
initialize_params { | ||
image = data.google_compute_image.my_image.self_link | ||
enable_confidential_compute = %{confidential_compute} | ||
type = "hyperdisk-balanced" | ||
} | ||
|
||
kms_key_self_link = "%{key_name}" | ||
} | ||
|
||
network_interface { | ||
network = "default" | ||
} | ||
depends_on = [google_kms_crypto_key_iam_binding.crypto_key] | ||
|
||
} | ||
`, context) | ||
} | ||
<% end -%> | ||
|
||
func testAccComputeInstance_enableDisplay(instance string) string { | ||
return fmt.Sprintf(` | ||
data "google_compute_image" "my_image" { | ||
|