Skip to content

Commit

Permalink
Add accelerators workstation config resource (GoogleCloudPlatform#8490)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielRieske authored Aug 1, 2023
1 parent 6acfb62 commit da45213
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
23 changes: 23 additions & 0 deletions mmv1/products/workstations/WorkstationConfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ examples:
vars:
workstation_cluster_name: 'workstation-cluster'
workstation_config_name: 'workstation-config'
- !ruby/object:Provider::Terraform::Examples
name: 'workstation_config_accelerators'
min_version: beta
primary_resource_id: 'default'
vars:
workstation_cluster_name: 'workstation-cluster'
workstation_config_name: 'workstation-config'
- !ruby/object:Provider::Terraform::Examples
name: 'workstation_config_encryption_key'
min_version: beta
Expand Down Expand Up @@ -263,6 +270,22 @@ properties:
description: |
Whether the instance has confidential compute enabled.
send_empty_value: true
- !ruby/object:Api::Type::Array
name: 'accelerators'
description: |
An accelerator card attached to the instance.
item_type: !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::String
name: 'type'
description: |
Type of accelerator resource to attach to the instance, for example, "nvidia-tesla-p100".
required: true
- !ruby/object:Api::Type::Integer
name: 'count'
description: |
Number of accelerator cards exposed to the instance.
required: true
- !ruby/object:Api::Type::Array
name: 'persistentDirectories'
description: |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
resource "google_compute_network" "default" {
provider = google-beta
name = "<%= ctx[:vars]['workstation_cluster_name'] %>"
auto_create_subnetworks = false
}

resource "google_compute_subnetwork" "default" {
provider = google-beta
name = "<%= ctx[: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" "<%= ctx[:primary_resource_id] %>" {
provider = google-beta
workstation_cluster_id = "<%= ctx[:vars]['workstation_cluster_name'] %>"
network = google_compute_network.default.id
subnetwork = google_compute_subnetwork.default.id
location = "us-central1"

labels = {
"label" = "key"
}

annotations = {
label-one = "value-one"
}
}

resource "google_workstations_workstation_config" "<%= ctx[:primary_resource_id] %>" {
provider = google-beta
workstation_config_id = "<%= ctx[:vars]['workstation_config_name'] %>"
workstation_cluster_id = google_workstations_workstation_cluster.<%= ctx[:primary_resource_id] %>.workstation_cluster_id
location = "us-central1"

host {
gce_instance {
machine_type = "n1-standard-2"
boot_disk_size_gb = 35
disable_public_ip_addresses = true
accelerators {
type = "nvidia-tesla-p100"
count = "1"
}
}
}
}

0 comments on commit da45213

Please sign in to comment.