Skip to content

Commit

Permalink
Promote enable_confidential_compute for disks to v1. (GoogleCloudPlat…
Browse files Browse the repository at this point in the history
…form#9789)

* Promote enable_confidential_compute for disks to v1.

* Enable confidential hyperdisk test for `google_compute_disk.
  • Loading branch information
harshulsoni authored and balanaguharsha committed May 2, 2024
1 parent 6c85a73 commit 6778dc9
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 19 deletions.
1 change: 0 additions & 1 deletion mmv1/products/compute/Disk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@ properties:
description: |
Whether this disk is using confidential compute mode.
Note: Only supported on hyperdisk skus, disk_encryption_key is required when setting to true
min_version: beta
required: false
default_from_api: true
- !ruby/object:Api::Type::Boolean
Expand Down
6 changes: 6 additions & 0 deletions mmv1/products/compute/Instance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ properties:
the disk, hyperdisk allows for an update of throughput every
4 hours. To update your hyperdisk more frequently,
you'll need to manually delete and recreate it.
- !ruby/object:Api::Type::Boolean
name: 'enableConfidentialCompute'
description: |
Whether this disk is using confidential compute mode.
Note: Only supported on hyperdisk skus, disk_encryption_key
is required when setting to true.
- !ruby/object:Api::Type::NestedObject
name: 'sourceImageEncryptionKey'
description: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,14 +560,16 @@ func TestAccComputeDisk_encryptionKMS(t *testing.T) {
})
}

<% unless version == 'ga' -%>
func TestAccComputeDisk_pdHyperDiskEnableConfidentialCompute(t *testing.T) {
t.Skip()
t.Parallel()

context := map[string]interface{}{
"random_suffix": acctest.RandString(t, 10),
"kms": acctest.BootstrapKMSKey(t).CryptoKey.Name, // global KMS key
"kms": acctest.BootstrapKMSKeyWithPurposeInLocationAndName(
t,
"ENCRYPT_DECRYPT",
"us-central1",
"tf-bootstrap-hyperdisk-key1").CryptoKey.Name, // regional KMS key
"disk_size": 64,
"confidential_compute": true,
}
Expand Down Expand Up @@ -596,7 +598,6 @@ func TestAccComputeDisk_pdHyperDiskEnableConfidentialCompute(t *testing.T) {
},
})
}
<% end -%>

func TestAccComputeDisk_deleteDetach(t *testing.T) {
t.Parallel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ var (
"boot_disk.0.initialize_params.0.resource_manager_tags",
"boot_disk.0.initialize_params.0.provisioned_iops",
"boot_disk.0.initialize_params.0.provisioned_throughput",
<% unless version == 'ga' -%>
"boot_disk.0.initialize_params.0.enable_confidential_compute",
<% end -%>
}

schedulingKeys = []string{
Expand Down Expand Up @@ -267,15 +265,13 @@ func ResourceComputeInstance() *schema.Resource {
Description: `Indicates how much throughput to provision for the disk. This sets the number of throughput mb per second that the disk can handle. Values must be between 1 and 7,124.`,
},

<% unless version == 'ga' -%>
"enable_confidential_compute": {
Type: schema.TypeBool,
Optional: true,
AtLeastOneOf: initializeParamsKeys,
ForceNew: true,
Description: `A flag to enable confidential compute mode on boot disk`,
},
<% end -%>
},
},
},
Expand Down Expand Up @@ -2832,11 +2828,9 @@ func expandBootDisk(d *schema.ResourceData, config *transport_tpg.Config, projec
disk.InitializeParams.ProvisionedThroughput = int64(v.(int))
}

<% unless version == 'ga' -%>
if v, ok := d.GetOk("boot_disk.0.initialize_params.0.enable_confidential_compute"); ok {
disk.InitializeParams.EnableConfidentialCompute = v.(bool)
}
<% end -%>

if v, ok := d.GetOk("boot_disk.0.initialize_params.0.type"); ok {
diskTypeName := v.(string)
Expand Down Expand Up @@ -2905,9 +2899,7 @@ func flattenBootDisk(d *schema.ResourceData, disk *compute.AttachedDisk, config
"resource_manager_tags": d.Get("boot_disk.0.initialize_params.0.resource_manager_tags"),
"provisioned_iops": diskDetails.ProvisionedIops,
"provisioned_throughput": diskDetails.ProvisionedThroughput,
<% unless version == 'ga' -%>
"enable_confidential_compute": diskDetails.EnableConfidentialCompute,
<% end -%>
}}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1822,8 +1822,6 @@ 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")
Expand Down Expand Up @@ -1862,7 +1860,6 @@ func TestAccComputeInstance_confidentialHyperDiskBootDisk(t *testing.T) {
},
})
}
<% end -%>

func TestAccComputeInstance_hyperdiskBootDisk_provisioned_iops_throughput(t *testing.T) {
t.Parallel()
Expand Down Expand Up @@ -7060,7 +7057,6 @@ 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" {
Expand All @@ -7078,7 +7074,7 @@ resource "google_kms_crypto_key_iam_member" "crypto_key" {

resource "google_compute_instance" "foobar" {
name = "%{instance_name}"
machine_type = "n2-standard-2"
machine_type = "h3-standard-88"
zone = "%{zone}"

boot_disk {
Expand All @@ -7100,7 +7096,6 @@ resource "google_compute_instance" "foobar" {
}
`, context)
}
<% end -%>

func testAccComputeInstanceHyperDiskBootDiskProvisionedIopsThroughput(context map[string]interface{}) string {
return acctest.Nprintf(`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ is desired, you will need to modify your state file manually using
recreate the disk, hyperdisk allows for an update of throughput every 4 hours.
To update your hyperdisk more frequently, you'll need to manually delete and recreate it.

* `enable_confidential_compute` - (Optional) Whether this disk is using confidential compute mode.
Note: Only supported on hyperdisk skus, disk_encryption_key is required when setting to true.

<a name="nested_scratch_disk"></a>The `scratch_disk` block supports:

* `interface` - (Required) The disk interface to use for attaching this disk; either SCSI or NVME.
Expand Down

0 comments on commit 6778dc9

Please sign in to comment.