diff --git a/mmv1/products/workstations/WorkstationConfig.yaml b/mmv1/products/workstations/WorkstationConfig.yaml index 38f61db0ce4d..84bbf55a3f3d 100644 --- a/mmv1/products/workstations/WorkstationConfig.yaml +++ b/mmv1/products/workstations/WorkstationConfig.yaml @@ -70,6 +70,16 @@ examples: vars: workstation_cluster_name: 'workstation-cluster' workstation_config_name: 'workstation-config' + - name: 'workstation_config_hyperdisk' + primary_resource_id: 'default' + vars: + workstation_cluster_name: 'workstation-cluster' + workstation_config_name: 'workstation-config' + - name: 'workstation_config_hyperdisk_source_snapshot' + primary_resource_id: 'default' + vars: + workstation_cluster_name: 'workstation-cluster' + workstation_config_name: 'workstation-config' - name: 'workstation_config_persistent_directories' primary_resource_id: 'default' vars: @@ -427,6 +437,30 @@ properties: description: | Name of the snapshot to use as the source for the disk. This can be the snapshot's `self_link`, `id`, or a string in the format of `projects/{project}/global/snapshots/{snapshot}`. If set, `sizeGb` and `fsType` must be empty. Can only be updated if it has an existing value. # TODO: Add conflicting fields once complex lists are supported. + - name: 'gceHd' + type: NestedObject + description: | + A directory to persist across workstation sessions, backed by a Compute Engine Hyperdisk Balanced High Availability disk. + properties: + - name: 'sizeGb' + type: Integer + description: | + The GB capacity of a persistent home directory. Defaults to '200'. + - name: 'sourceSnapshot' + type: String + description: | + Name of the snapshot to use as the source for the disk. + - name: 'reclaimPolicy' + type: Enum + description: | + Whether the persistent disk should be deleted when the workstation is deleted. + enum_values: + - 'DELETE' + - 'RETAIN' + - name: 'archiveTimeout' + type: String + description: | + How long to wait before converting the disk into a snapshot. - name: 'ephemeralDirectories' type: Array description: | diff --git a/mmv1/templates/terraform/examples/workstation_config_hyperdisk.tf.tmpl b/mmv1/templates/terraform/examples/workstation_config_hyperdisk.tf.tmpl new file mode 100644 index 000000000000..d4e2fcf126d1 --- /dev/null +++ b/mmv1/templates/terraform/examples/workstation_config_hyperdisk.tf.tmpl @@ -0,0 +1,41 @@ +resource "google_compute_network" "default" { + name = "{{index $.Vars "workstation_cluster_name"}}" + auto_create_subnetworks = false +} + +resource "google_compute_subnetwork" "default" { + name = "{{index $.Vars "workstation_cluster_name"}}" + ip_cidr_range = "10.0.0.0/24" + region = "us-central1" + network = google_compute_network.default.name +} + +resource "google_workstations_workstation_cluster" "{{$.PrimaryResourceId}}" { + workstation_cluster_id = "{{index $.Vars "workstation_cluster_name"}}" + network = google_compute_network.default.id + subnetwork = google_compute_subnetwork.default.id + location = "us-central1" +} + +resource "google_workstations_workstation_config" "{{$.PrimaryResourceId}}" { + workstation_config_id = "{{index $.Vars "workstation_config_name"}}" + workstation_cluster_id = google_workstations_workstation_cluster.{{$.PrimaryResourceId}}.workstation_cluster_id + location = "us-central1" + + host { + gce_instance { + # C3 machine types require Hyperdisk storage + machine_type = "c3-standard-22" + } + } + + persistent_directories { + mount_path = "/home" + gce_hd { + size_gb = 200 + max_size_gb = 500 + reclaim_policy = "DELETE" + archive_timeout = "3600s" + } + } +} diff --git a/mmv1/templates/terraform/examples/workstation_config_hyperdisk_source_snapshot.tf.tmpl b/mmv1/templates/terraform/examples/workstation_config_hyperdisk_source_snapshot.tf.tmpl new file mode 100644 index 000000000000..37a83723fb19 --- /dev/null +++ b/mmv1/templates/terraform/examples/workstation_config_hyperdisk_source_snapshot.tf.tmpl @@ -0,0 +1,51 @@ +resource "google_compute_network" "default" { + name = "{{index $.Vars "workstation_cluster_name"}}" + auto_create_subnetworks = false +} + +resource "google_compute_subnetwork" "default" { + name = "{{index $.Vars "workstation_cluster_name"}}" + ip_cidr_range = "10.0.0.0/24" + region = "us-central1" + network = google_compute_network.default.name +} + +resource "google_compute_disk" "my_source_disk" { + name = "{{index $.Vars "workstation_config_name"}}-source-disk" + size = 10 + type = "pd-ssd" + zone = "us-central1-a" +} + +resource "google_compute_snapshot" "my_source_snapshot" { + name = "{{index $.Vars "workstation_config_name"}}-source-snapshot" + source_disk = google_compute_disk.my_source_disk.name + zone = "us-central1-a" +} + +resource "google_workstations_workstation_cluster" "default" { + workstation_cluster_id = "{{index $.Vars "workstation_cluster_name"}}" + network = google_compute_network.default.id + subnetwork = google_compute_subnetwork.default.id + location = "us-central1" +} + +resource "google_workstations_workstation_config" "{{$.PrimaryResourceId}}" { + workstation_config_id = "{{index $.Vars "workstation_config_name"}}" + workstation_cluster_id = google_workstations_workstation_cluster.default.workstation_cluster_id + location = "us-central1" + + host { + gce_instance { + machine_type = "c3-standard-22" + } + } + + persistent_directories { + mount_path = "/home" + gce_hd { + source_snapshot = google_compute_snapshot.my_source_snapshot.id + reclaim_policy = "DELETE" + } + } +}