terraform-provider-vsphere icon indicating copy to clipboard operation
terraform-provider-vsphere copied to clipboard

feat: add support for volume encryption

Open belleatkins opened this issue 2 years ago • 13 comments

###Description As per issue: (https://github.com/hashicorp/terraform-provider-vsphere/issues/1796) This MR is to add Volume Encryption Support for deploying in VSphere. It does this by running additional post-deployment steps to set the storage policy separately (to get around the fact that vSphere doesn't support setting the storage policy on disk attachment). It runs an additional step to revert the name change that occurs under foot.

A storage policy would be specified in the main.tf as follows:

`resource "vsphere_virtual_machine" "belle-pcc_vms" {
  clone {
    template_uuid    = data.vsphere_virtual_machine.template.id
  }
  count              = 1
  scsi_type          = data.vsphere_virtual_machine.template.scsi_type
  datastore_id       = data.vsphere_datastore.datastore[count.index].id
  storage_policy_id  = data.vsphere_storage_policy.policy[count.index].id

  depends_on         = [local_file.user_data_json]
  disk {
    datastore_id        = data.vsphere_datastore.datastore[count.index].id
    label               = "disk0"
    keep_on_remove      = false
    size                = var.boot_disk_size
    thin_provisioned    = true
    storage_policy_id   = data.vsphere_storage_policy.policy[count.index].id
  }
  disk {
    datastore_id        = data.vsphere_datastore.datastore[count.index].id
    label               = "disk1"
    unit_number         = 1
    attach              = true
    path                = vsphere_virtual_disk.disk[count.index].vmdk_path
    storage_policy_id   = data.vsphere_storage_policy.policy[count.index].id
  }`

Use of this feature requires the correct VSphere Cryptography permissions.

Acceptance tests Have you added an acceptance test for the functionality being added? Have you run the acceptance tests on this branch? [ ] I have not run acceptance tests as my vsphere environment does not have access to any NAS storage, so I cannot set environment variable TF_VAR_VSPHERE_NAS_HOST or TF_VAR_VSPHERE_NFS_PATH, so tests are failing with

make testacc TESTARGS="-run=TestAccResourceVSphereVirtualMachine_basic"
Error: error mounting datastore: host "<TF_VAR_VSPHERE_ESXI2>": ServerFaultCode: A specified parameter was not correct:

  with vsphere_nas_datastore.ds1,
  on terraform_plugin_test.tf line 29, in resource "vsphere_nas_datastore" "ds1":
  29: resource "vsphere_nas_datastore" "ds1" {

I'd appreciate guidance on how to get around this, and which acceptance tests to run if it is possible.

Manual testing of this feature is complete. This feature is now used in our product. Manual testing included test sessions under:

  • performance
  • robustness and resiliency
  • deleting the VM and attaching a new VM to the existing encrypted disks
  • deploying a VM with fresh encrypted disks
  • One bug was found and fixed: datastores containing the encrypted disks were not successfully detected when inside a folder
  • a light cross spectrum of storage policies were tried and tested

Release Note Release note for CHANGELOG: FEATURES:

virtual_machine_disk_subresource: Add support for deploying a VM with encrypted disks via specifying a storage policy which has encryption enabled. ...

References

Closes #1796

belleatkins avatar Feb 13 '23 11:02 belleatkins

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes


1 out of 2 committers have signed the CLA.

  • [x] belleatkins
  • [ ] martons-msw

Have you signed the CLA already but the status is still pending? Recheck it.

hashicorp-cla avatar Feb 13 '23 11:02 hashicorp-cla

Marking as draft due to merge conflicts.

tenthirtyam avatar Mar 11 '23 05:03 tenthirtyam

CI is failing.

==> Checking that code complies with gofmt requirements...
[5](https://github.com/hashicorp/terraform-provider-vsphere/actions/runs/4447034308/jobs/7808976110#step:5:6)
gofmt needs running on the following files:
[6](https://github.com/hashicorp/terraform-provider-vsphere/actions/runs/4447034308/jobs/7808976110#step:5:7)
make: *** [GNUmakefile:27: fmtcheck] Error 1
[7](https://github.com/hashicorp/terraform-provider-vsphere/actions/runs/4447034308/jobs/7808976110#step:5:8)
./vsphere/internal/virtualdevice/virtual_machine_disk_subresource.go
[8](https://github.com/hashicorp/terraform-provider-vsphere/actions/runs/4447034308/jobs/7808976110#step:5:9)
./vsphere/data_source_vsphere_host.go
[9](https://github.com/hashicorp/terraform-provider-vsphere/actions/runs/4447034308/jobs/7808976110#step:5:10)
You can use the command: `make fmt` to reformat code.
[10](https://github.com/hashicorp/terraform-provider-vsphere/actions/runs/4447034308/jobs/7808976110#step:5:11)
Error: Process completed with exit code 2.

tenthirtyam avatar Mar 17 '23 14:03 tenthirtyam

fixed CI

belleatkins avatar Mar 17 '23 14:03 belleatkins

CI Failing

==> Checking that code complies with gofmt requirements...
[5](https://github.com/hashicorp/terraform-provider-vsphere/actions/runs/4448677556/jobs/7812906362?pr=1839#step:5:6)
gofmt needs running on the following files:
[6](https://github.com/hashicorp/terraform-provider-vsphere/actions/runs/4448677556/jobs/7812906362?pr=1839#step:5:7)
./vsphere/internal/virtualdevice/virtual_machine_disk_subresource.go
[7](https://github.com/hashicorp/terraform-provider-vsphere/actions/runs/4448677556/jobs/7812906362?pr=1839#step:5:8)
make: *** [GNUmakefile:27: fmtcheck] Error 1
[8](https://github.com/hashicorp/terraform-provider-vsphere/actions/runs/4448677556/jobs/7812906362?pr=1839#step:5:9)
./vsphere/data_source_vsphere_host.go
[9](https://github.com/hashicorp/terraform-provider-vsphere/actions/runs/4448677556/jobs/7812906362?pr=1839#step:5:10)
You can use the command: `make fmt` to reformat code.
[10](https://github.com/hashicorp/terraform-provider-vsphere/actions/runs/4448677556/jobs/7812906362?pr=1839#step:5:11)
Error: Process completed with exit code 2.

tenthirtyam avatar Mar 17 '23 15:03 tenthirtyam

fixed CI

belleatkins avatar Mar 17 '23 16:03 belleatkins

CI Passing

tenthirtyam avatar Mar 18 '23 00:03 tenthirtyam

Marked as draft as this needs an acceptance test and there are no updates on manual testing per OP.

tenthirtyam avatar May 08 '23 13:05 tenthirtyam

Marked as draft as this needs an acceptance test and there are no updates on manual testing per OP.

manual testing completed

belleatkins avatar Jul 24 '23 09:07 belleatkins

Hi @belleatkins! There are still merge conflicts for this one that need to be addressed.

Hi @martons-msw! You'll need to sign the HashiCorp CLA before this can be reviewed and merged.

tenthirtyam avatar Nov 10 '23 20:11 tenthirtyam

Hi @belleatkins! There are still merge conflicts for this one that need to be addressed.

Hi @martons-msw! You'll need to sign the HashiCorp CLA before this can be reviewed and merged.

tenthirtyam avatar Nov 30 '23 02:11 tenthirtyam

Hello, any news on this topic ?

DariusMR avatar Jan 18 '24 08:01 DariusMR

Hi @martons-msw! You'll need to sign the HashiCorp CLA before this can be reviewed and merged.

tenthirtyam avatar Feb 13 '24 00:02 tenthirtyam

There haven't been any updates.

  • @belleatkins - there were still merge conflicts for this one that need to be addressed.

  • @martons-msw! - the HashiCorp CLA needed to be signed.

I'm closing this pull request for now. Please feel free to create a new pull request if this feature is still desired.

tenthirtyam avatar Apr 30 '24 20:04 tenthirtyam

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

github-actions[bot] avatar Jun 16 '24 02:06 github-actions[bot]