hashicorp / terraform-provider-googleworkspace

Terraform Provider for Google Workspace
https://registry.terraform.io/providers/hashicorp/googleworkspace
Mozilla Public License 2.0
129 stars 56 forks source link

Ability to transfer user data before deletion #397

Open tammersaleh opened 1 year ago

tammersaleh commented 1 year ago

Affected Resource(s)

Feature Request

When I delete a google workspace user from the admin interface, I'm allowed to transfer their data as part of the process. (see this doc)

We're transitioning to managing all google users through this provider and would like to retain this functionality. I imagine a new block could be added to the resource like such:

resource "googleworkspace_user" "dwight" {
  primary_email = "dwight.schrute@example.com"
  ...

  transfer_data_upon_deletion {
    target_user_email = "admin@example.com"
    transfer_email = true
    transfer_drive_files = true
    transfer_...
  }

Potential Issues

I'm unsure how the admin console juggles data transfer before user deletion. If Terraform initiates the data transfer and then deletes the user, will Google know to queue the deletion to happen after the transfer finishes, or will the deletion call fail? (or worse: will the transfer be aborted?)

References

A quick search makes me think this is the data transfer API used by the admin console.

enchorb commented 1 year ago

+1

SamuZad commented 2 months ago

I finally had time to implement this for my fork 😅

https://registry.terraform.io/providers/SamuZad/googleworkspace/latest/docs/resources/user#nestedblock--on_delete_data_transfer

https://github.com/SamuZad/terraform-provider-googleworkspace/commit/834b20a9187ca8f4f1721c79c39cdf5f201f9361