From a966f6ceec33434af0b0650470f2afdb8c22bab4 Mon Sep 17 00:00:00 2001 From: Bhargav Chereddy Date: Thu, 31 Oct 2024 21:26:11 +0000 Subject: [PATCH 01/28] update documentation for instance_owners field --- mmv1/products/workbench/Instance.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mmv1/products/workbench/Instance.yaml b/mmv1/products/workbench/Instance.yaml index 06b7f5329bb9..6c453f60a76e 100644 --- a/mmv1/products/workbench/Instance.yaml +++ b/mmv1/products/workbench/Instance.yaml @@ -449,7 +449,9 @@ properties: description: | 'Optional. Input only. The owner of this instance after creation. Format: `alias@example.com` Currently supports one owner only. If not specified, all of - the service account users of your VM instance''s service account can use the instance.' + the service account users of your VM instance''s service account can use the instance. + Sets the access mode to `Single user`. For more details, see + https://cloud.google.com/vertex-ai/docs/workbench/instances/manage-access-jupyterlab' immutable: true ignore_read: true item_type: From 71e2553bb30862cd36f65391561efbdab996377f Mon Sep 17 00:00:00 2001 From: Bhargav Chereddy Date: Thu, 31 Oct 2024 21:30:33 +0000 Subject: [PATCH 02/28] update documentation for instance_owners field --- mmv1/products/workbench/Instance.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/products/workbench/Instance.yaml b/mmv1/products/workbench/Instance.yaml index 6c453f60a76e..0e26ad1412ae 100644 --- a/mmv1/products/workbench/Instance.yaml +++ b/mmv1/products/workbench/Instance.yaml @@ -450,7 +450,7 @@ properties: 'Optional. Input only. The owner of this instance after creation. Format: `alias@example.com` Currently supports one owner only. If not specified, all of the service account users of your VM instance''s service account can use the instance. - Sets the access mode to `Single user`. For more details, see + If specified, sets the access mode to `Single user`. For more details, see https://cloud.google.com/vertex-ai/docs/workbench/instances/manage-access-jupyterlab' immutable: true ignore_read: true From 6a7ddbb6136edde6cc58d74b66823b29cdcc2765 Mon Sep 17 00:00:00 2001 From: Bhargav Chereddy Date: Thu, 31 Oct 2024 21:34:55 +0000 Subject: [PATCH 03/28] lint fix --- mmv1/products/workbench/Instance.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/products/workbench/Instance.yaml b/mmv1/products/workbench/Instance.yaml index 0e26ad1412ae..846936c4235e 100644 --- a/mmv1/products/workbench/Instance.yaml +++ b/mmv1/products/workbench/Instance.yaml @@ -450,7 +450,7 @@ properties: 'Optional. Input only. The owner of this instance after creation. Format: `alias@example.com` Currently supports one owner only. If not specified, all of the service account users of your VM instance''s service account can use the instance. - If specified, sets the access mode to `Single user`. For more details, see + If specified, sets the access mode to `Single user`. For more details, see https://cloud.google.com/vertex-ai/docs/workbench/instances/manage-access-jupyterlab' immutable: true ignore_read: true From 268e2ae980e9dee415ef5b4ffddc534297eda350 Mon Sep 17 00:00:00 2001 From: Bhargav Chereddy Date: Thu, 5 Dec 2024 21:50:43 +0000 Subject: [PATCH 04/28] gcs-data-bucket is now modifiable by the customer --- mmv1/templates/terraform/constants/workbench_instance.go.tmpl | 1 - 1 file changed, 1 deletion(-) diff --git a/mmv1/templates/terraform/constants/workbench_instance.go.tmpl b/mmv1/templates/terraform/constants/workbench_instance.go.tmpl index 19a572094435..b9091e398358 100644 --- a/mmv1/templates/terraform/constants/workbench_instance.go.tmpl +++ b/mmv1/templates/terraform/constants/workbench_instance.go.tmpl @@ -42,7 +42,6 @@ var WorkbenchInstanceProvidedMetadata = []string{ "dataproc-service-account", "disable-check-xsrf", "framework", - "gcs-data-bucket", "generate-diagnostics-bucket", "generate-diagnostics-file", "generate-diagnostics-options", From c9e07e691abb1d0ea011a2cb5b676120bf2995da Mon Sep 17 00:00:00 2001 From: Bhargav Chereddy Date: Wed, 18 Dec 2024 19:02:19 +0000 Subject: [PATCH 05/28] Add suport for Third Party Identity --- mmv1/products/workbench/Instance.yaml | 5 +++++ .../terraform/examples/workbench_instance_full.tf.tmpl | 2 ++ 2 files changed, 7 insertions(+) diff --git a/mmv1/products/workbench/Instance.yaml b/mmv1/products/workbench/Instance.yaml index 846936c4235e..f70caa8cefca 100644 --- a/mmv1/products/workbench/Instance.yaml +++ b/mmv1/products/workbench/Instance.yaml @@ -549,3 +549,8 @@ properties: Optional. Labels to apply to this instance. These can be later modified by the UpdateInstance method. diff_suppress_func: 'WorkbenchInstanceLabelsDiffSuppress' + - name: 'enableThirdPartyIdentity' + type: Boolean + description: | + Flag that specifies that a notebook can be accessed with third party + identity provider. diff --git a/mmv1/templates/terraform/examples/workbench_instance_full.tf.tmpl b/mmv1/templates/terraform/examples/workbench_instance_full.tf.tmpl index 2252af59b8e1..97f8ee97306e 100644 --- a/mmv1/templates/terraform/examples/workbench_instance_full.tf.tmpl +++ b/mmv1/templates/terraform/examples/workbench_instance_full.tf.tmpl @@ -88,4 +88,6 @@ resource "google_workbench_instance" "{{$.PrimaryResourceId}}" { desired_state = "ACTIVE" + enable_third_party_identity = "true" + } From 92170cef7139a01a7321880a668cc6f0bde7f2d7 Mon Sep 17 00:00:00 2001 From: Bhargav Chereddy Date: Mon, 6 Jan 2025 22:21:32 +0000 Subject: [PATCH 06/28] Colab runtime template draft --- mmv1/products/colab/RuntimeTemplate.yaml | 169 ++++++++++++++++++ mmv1/products/colab/product.yaml | 25 +++ .../colab_runtime_template_basic.tf.tmpl | 5 + .../colab_runtime_template_full.tf.tmpl | 5 + 4 files changed, 204 insertions(+) create mode 100644 mmv1/products/colab/RuntimeTemplate.yaml create mode 100644 mmv1/products/colab/product.yaml create mode 100644 mmv1/templates/terraform/examples/colab_runtime_template_basic.tf.tmpl create mode 100644 mmv1/templates/terraform/examples/colab_runtime_template_full.tf.tmpl diff --git a/mmv1/products/colab/RuntimeTemplate.yaml b/mmv1/products/colab/RuntimeTemplate.yaml new file mode 100644 index 000000000000..f595d20de7da --- /dev/null +++ b/mmv1/products/colab/RuntimeTemplate.yaml @@ -0,0 +1,169 @@ +# Copyright 2025 Google Inc. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- + +name: 'RuntimeTemplate' +description: | + 'A runtime template is a VM configuration that specifies a machine type and other characteristics of the VM, + as well as common settings such as the network and whether public internet access is enabled. When you create + a runtime, its VM is created according to the specifications of a runtime template.' + +references: + guides: + 'Create a runtime template': 'https://cloud.google.com/colab/docs/create-runtime-template' + api: 'https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.notebookRuntimeTemplates' +base_url: 'projects/{{project}}/locations/{{location}}/notebookRuntimeTemplates' +self_link: 'projects/{{project}}/locations/{{location}}/notebookRuntimeTemplates/{{name}}' +immutable: true +create_url: 'projects/{{project}}/locations/{{location}}/notebookRuntimeTemplates?resourceId={{name}}' +autogen_async: true +async: + operation: + base_url: '{{op_id}}' +examples: + - name: 'colab_runtime_template_basic' + primary_resource_id: 'runtime-template' + primary_resource_name: 'fmt.Sprintf("tf-test-colab-runtime-template%s", context["random_suffix"])' + region_override: 'us-central1' + vars: + runtime_template_name: 'colab-runtime-template' + - name: 'colab_runtime_template_full' + primary_resource_id: 'runtime-template' + primary_resource_name: 'fmt.Sprintf("tf-test-colab-runtime-template%s", context["random_suffix"])' + region_override: 'us-central1' + vars: + runtime_template_name: 'colab-runtime-template' +parameters: + - name: 'location' + type: String + required: true + immutable: true + url_param_only: true + description: | + The location for the resource: https://cloud.google.com/colab/docs/locations +properties: + - name: 'name' + type: String + required: true + immutable: true + url_param_only: true + description: | + 'The resource name of the Runtime Template' + - name: 'displayName' + type: String + description: + Required. The display name of the Runtime Template. + required: true + - name: RuntimeTemplateConfig + type: NestedObject + description: | + "Configuration of the runtime template" + properties: + - name: description + type: String + description: 'The description of the Runtime Template.' + - name: machineConfig + type: NestedObject + description: "The machine configuration of the runtime." + properties: + - name: 'machineType' + type: string + description: | + The Compute Engine machine type selected for the runtime. + default_from_api: true + - name: 'acceleratorType' + type: enum + description: | + The type of hardware accelerator used by the runtime. If specified, acceleratorCount must also be specified. + enum_values: + - 'NVIDIA_TESLA_V100' + - 'NVIDIA_TESLA_T4' + - 'NVIDIA_TESLA_A100' + - 'NVIDIA_A100_80GB' + - 'NVIDIA_L4' + - name: 'acceleratorCount' + type: int + description: | + The number of accelerators used by the runtime. + - name: dataDiskConfig + type: NestedObject + description: | + "The configuration for the data disk of the runtime." + properties: + - name: 'diskType' + type: enum + description: | + The type of the persistent disk. + enum_values: + - 'PD_STANDARD' + - 'PD_SSD' + - 'PD_BALANCED' + - 'PD_EXTREME' + - name: 'diskSizeGb' + type: int + description: | + The disk size of the runtime in GB. If specified, the diskType must also be specified. The minimum size is 10GB and the maximum is 65536GB. + default_from_api: true + - name: NetworkConfig + type: NestedObject + description: | + "The network configuration for the runtime." + properties: + - name: 'enableInternetAccess' + type: bool + description: | + Enable public internet access for the runtime. Enabled by default. + default_from_api: true + - name: 'network' + type: String + description: | + The name of the VPC that this runtime is in. + default_from_api: true + diff_suppress_func: 'tpgresource.CompareSelfLinkRelativePaths' + - name: 'subnetwork' + type: String + description: | + The name of the VPC that this runtime is in. + default_from_api: true + diff_suppress_func: 'tpgresource.CompareSelfLinkRelativePaths' + - name: 'labels' + type: string + description: | + 'Labels to identify and group the runtime template.' + - name: 'idleShutdownTimeout' + type: string + description: | + 'The duration after which the runtime is automatically shut down. An input of 0s disables the idle shutdown feature, and a valid range is [10m, 24h].' + - name: 'enableEuc' + type: bool + description: | + 'Enable end user credential access for the runtime. Enabled by default.' + - name: 'enableSecureBoot' + type: bool + description: | + 'Enables secure boot for the runtime. Disabled by default.' + - name: 'networkTags' + type: Array + item_type: + type: String + description: | + 'Applies the given Compute Engine tags to the runtime.' + - name: 'kmsKey' + type: String + description: | + 'The Cloud KMS encryption key (customer-managed encryption key) used to protect the runtime.' + - name: 'runtimeTemplateId' + type: String + description: + The id of the runtime template. If not specified, a random id will be generated. \ No newline at end of file diff --git a/mmv1/products/colab/product.yaml b/mmv1/products/colab/product.yaml new file mode 100644 index 000000000000..74ebc92e709a --- /dev/null +++ b/mmv1/products/colab/product.yaml @@ -0,0 +1,25 @@ +# Copyright 2025 Google Inc. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- +name: 'Colab' +display_name: 'Colab Enterprise' +versions: + - name: 'ga' + base_url: 'https://{{region}}-aiplatform.googleapis.com/v1/' + cai_base_url: 'https://aiplatform.googleapis.com/v1/' + - name: 'beta' + base_url: 'https://{{region}}-aiplatform.googleapis.com/v1beta1/' + cai_base_url: 'https://aiplatform.googleapis.com/v1beta1/' +scopes: + - 'https://www.googleapis.com/auth/cloud-platform' \ No newline at end of file diff --git a/mmv1/templates/terraform/examples/colab_runtime_template_basic.tf.tmpl b/mmv1/templates/terraform/examples/colab_runtime_template_basic.tf.tmpl new file mode 100644 index 000000000000..f17f8d8ec073 --- /dev/null +++ b/mmv1/templates/terraform/examples/colab_runtime_template_basic.tf.tmpl @@ -0,0 +1,5 @@ +resource "google_colab_runtime_template" "{{$.PrimaryResourceId}}" { + name = "{{index $.Vars "runtime_template_name"}}" + displayName = "Runtime template full" + location = "us-central1" +} \ No newline at end of file diff --git a/mmv1/templates/terraform/examples/colab_runtime_template_full.tf.tmpl b/mmv1/templates/terraform/examples/colab_runtime_template_full.tf.tmpl new file mode 100644 index 000000000000..f17f8d8ec073 --- /dev/null +++ b/mmv1/templates/terraform/examples/colab_runtime_template_full.tf.tmpl @@ -0,0 +1,5 @@ +resource "google_colab_runtime_template" "{{$.PrimaryResourceId}}" { + name = "{{index $.Vars "runtime_template_name"}}" + displayName = "Runtime template full" + location = "us-central1" +} \ No newline at end of file From 0b90b9bc8d07eb251b84f6ee61d5c46cfe2a8b2b Mon Sep 17 00:00:00 2001 From: Bhargav Chereddy Date: Mon, 6 Jan 2025 22:23:17 +0000 Subject: [PATCH 07/28] Ignore changes to other resources --- mmv1/products/workbench/Instance.yaml | 7 +------ .../terraform/examples/workbench_instance_full.tf.tmpl | 2 -- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/mmv1/products/workbench/Instance.yaml b/mmv1/products/workbench/Instance.yaml index b6e18b678194..7c696f3e6e91 100644 --- a/mmv1/products/workbench/Instance.yaml +++ b/mmv1/products/workbench/Instance.yaml @@ -542,9 +542,4 @@ properties: description: | Optional. Labels to apply to this instance. These can be later modified by the UpdateInstance method. - diff_suppress_func: 'WorkbenchInstanceLabelsDiffSuppress' - - name: 'enableThirdPartyIdentity' - type: Boolean - description: | - Flag that specifies that a notebook can be accessed with third party - identity provider. + diff_suppress_func: 'WorkbenchInstanceLabelsDiffSuppress' \ No newline at end of file diff --git a/mmv1/templates/terraform/examples/workbench_instance_full.tf.tmpl b/mmv1/templates/terraform/examples/workbench_instance_full.tf.tmpl index 97f8ee97306e..2252af59b8e1 100644 --- a/mmv1/templates/terraform/examples/workbench_instance_full.tf.tmpl +++ b/mmv1/templates/terraform/examples/workbench_instance_full.tf.tmpl @@ -88,6 +88,4 @@ resource "google_workbench_instance" "{{$.PrimaryResourceId}}" { desired_state = "ACTIVE" - enable_third_party_identity = "true" - } From 6893114d822fa6cdc670d62a4bbb7b4ef8bed912 Mon Sep 17 00:00:00 2001 From: Bhargav Chereddy Date: Mon, 6 Jan 2025 22:24:03 +0000 Subject: [PATCH 08/28] Add empty space --- mmv1/products/workbench/Instance.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/products/workbench/Instance.yaml b/mmv1/products/workbench/Instance.yaml index 7c696f3e6e91..94d727e1e0e9 100644 --- a/mmv1/products/workbench/Instance.yaml +++ b/mmv1/products/workbench/Instance.yaml @@ -542,4 +542,4 @@ properties: description: | Optional. Labels to apply to this instance. These can be later modified by the UpdateInstance method. - diff_suppress_func: 'WorkbenchInstanceLabelsDiffSuppress' \ No newline at end of file + diff_suppress_func: 'WorkbenchInstanceLabelsDiffSuppress' From e9845f31bc6a9d5cd32ea97331c855e39cb6e12a Mon Sep 17 00:00:00 2001 From: Bhargav Chereddy Date: Wed, 8 Jan 2025 00:12:53 +0000 Subject: [PATCH 09/28] Add examples for templates --- mmv1/products/colab/RuntimeTemplate.yaml | 196 +++++++++--------- .../colab_runtime_template_basic.tf.tmpl | 11 +- .../colab_runtime_template_full.tf.tmpl | 63 +++++- 3 files changed, 172 insertions(+), 98 deletions(-) diff --git a/mmv1/products/colab/RuntimeTemplate.yaml b/mmv1/products/colab/RuntimeTemplate.yaml index f595d20de7da..a5d361ac8b98 100644 --- a/mmv1/products/colab/RuntimeTemplate.yaml +++ b/mmv1/products/colab/RuntimeTemplate.yaml @@ -26,7 +26,7 @@ references: base_url: 'projects/{{project}}/locations/{{location}}/notebookRuntimeTemplates' self_link: 'projects/{{project}}/locations/{{location}}/notebookRuntimeTemplates/{{name}}' immutable: true -create_url: 'projects/{{project}}/locations/{{location}}/notebookRuntimeTemplates?resourceId={{name}}' +create_url: 'projects/{{project}}/locations/{{location}}/notebookRuntimeTemplates?notebook_runtime_template_id={{name}}' autogen_async: true async: operation: @@ -44,6 +44,13 @@ examples: region_override: 'us-central1' vars: runtime_template_name: 'colab-runtime-template' + network_name: 'colab-test-default' + key_name: 'my-crypto-key' + test_env_vars: + project_id: 'PROJECT_NAME' + service_account: 'SERVICE_ACCT' + test_vars_overrides: + 'key_name': 'acctest.BootstrapKMSKeyInLocation(t, "us-central1").CryptoKey.Name' parameters: - name: 'location' type: String @@ -55,7 +62,6 @@ parameters: properties: - name: 'name' type: String - required: true immutable: true url_param_only: true description: | @@ -65,105 +71,109 @@ properties: description: Required. The display name of the Runtime Template. required: true - - name: RuntimeTemplateConfig + - name: description + type: String + description: 'The description of the Runtime Template.' + - name: machineSpec type: NestedObject + default_from_api: true description: | - "Configuration of the runtime template" + "The machine configuration of the runtime." properties: - - name: description - type: String - description: 'The description of the Runtime Template.' - - name: machineConfig - type: NestedObject - description: "The machine configuration of the runtime." - properties: - - name: 'machineType' - type: string - description: | - The Compute Engine machine type selected for the runtime. - default_from_api: true - - name: 'acceleratorType' - type: enum - description: | - The type of hardware accelerator used by the runtime. If specified, acceleratorCount must also be specified. - enum_values: - - 'NVIDIA_TESLA_V100' - - 'NVIDIA_TESLA_T4' - - 'NVIDIA_TESLA_A100' - - 'NVIDIA_A100_80GB' - - 'NVIDIA_L4' - - name: 'acceleratorCount' - type: int - description: | - The number of accelerators used by the runtime. - - name: dataDiskConfig - type: NestedObject - description: | - "The configuration for the data disk of the runtime." - properties: - - name: 'diskType' - type: enum - description: | - The type of the persistent disk. - enum_values: - - 'PD_STANDARD' - - 'PD_SSD' - - 'PD_BALANCED' - - 'PD_EXTREME' - - name: 'diskSizeGb' - type: int - description: | - The disk size of the runtime in GB. If specified, the diskType must also be specified. The minimum size is 10GB and the maximum is 65536GB. - default_from_api: true - - name: NetworkConfig - type: NestedObject - description: | - "The network configuration for the runtime." - properties: - - name: 'enableInternetAccess' - type: bool - description: | - Enable public internet access for the runtime. Enabled by default. - default_from_api: true - - name: 'network' - type: String - description: | - The name of the VPC that this runtime is in. - default_from_api: true - diff_suppress_func: 'tpgresource.CompareSelfLinkRelativePaths' - - name: 'subnetwork' - type: String - description: | - The name of the VPC that this runtime is in. - default_from_api: true - diff_suppress_func: 'tpgresource.CompareSelfLinkRelativePaths' - - name: 'labels' + - name: 'machineType' + required: true type: string description: | - 'Labels to identify and group the runtime template.' - - name: 'idleShutdownTimeout' - type: string + The Compute Engine machine type selected for the runtime. + default_from_api: true + - name: 'acceleratorType' + type: enum description: | - 'The duration after which the runtime is automatically shut down. An input of 0s disables the idle shutdown feature, and a valid range is [10m, 24h].' - - name: 'enableEuc' - type: bool + The type of hardware accelerator used by the runtime. If specified, acceleratorCount must also be specified. + enum_values: + - 'NVIDIA_TESLA_V100' + - 'NVIDIA_TESLA_T4' + - 'NVIDIA_TESLA_A100' + - 'NVIDIA_A100_80GB' + - 'NVIDIA_L4' + - name: 'acceleratorCount' + type: Integer + default_from_api: true description: | - 'Enable end user credential access for the runtime. Enabled by default.' - - name: 'enableSecureBoot' - type: bool + The number of accelerators used by the runtime. + - name: dataPersistentDiskSpec + type: NestedObject + default_from_api: true + description: "The configuration for the data disk of the runtime." + properties: + - name: 'diskType' + type: enum description: | - 'Enables secure boot for the runtime. Disabled by default.' - - name: 'networkTags' - type: Array - item_type: - type: String + The type of the persistent disk. + enum_values: + - 'pd-standard' + - 'pd-ssd' + - 'pd-balanced' + - 'pd-extreme' + - name: 'diskSizeGb' + type: int description: | - 'Applies the given Compute Engine tags to the runtime.' - - name: 'kmsKey' + The disk size of the runtime in GB. If specified, the diskType must also be specified. The minimum size is 10GB and the maximum is 65536GB. + - name: networkSpec + type: NestedObject + default_from_api: true + description: | + "The network configuration for the runtime." + properties: + - name: 'enableInternetAccess' + type: Boolean + description: Enable public internet access for the runtime. Enabled by default. + default_from_api: true + - name: 'network' + type: String + description: The name of the VPC that this runtime is in. + default_from_api: true + diff_suppress_func: 'tpgresource.CompareSelfLinkRelativePaths' + - name: 'subnetwork' type: String description: | - 'The Cloud KMS encryption key (customer-managed encryption key) used to protect the runtime.' - - name: 'runtimeTemplateId' - type: String - description: - The id of the runtime template. If not specified, a random id will be generated. \ No newline at end of file + The name of the VPC that this runtime is in. + default_from_api: true + diff_suppress_func: 'tpgresource.CompareSelfLinkRelativePaths' + - name: 'labels' + type: KeyValueLabels + description: 'Labels to identify and group the runtime template.' + - name: idleShutdownConfig + type: NestedObject + default_from_api: true + description: "Notebook Idle Shutdown configuration for the runtime." + properties: + - name: 'idleTimeout' + type: String + description: 'The duration after which the runtime is automatically shut down. An input of 0s disables the idle shutdown feature, and a valid range is [10m, 24h].' + - name: eucConfig + type: NestedObject + description: "EUC configuration of the NotebookRuntimeTemplate." + properties: + - name: 'eucDisabled' + type: Boolean + description: 'Enable end user credential access for the runtime.' + - name: shieldedVmConfig + type: NestedObject + description: "Runtime Shielded VM spec." + properties: + - name: 'enableSecureBoot' + type: Boolean + description: 'Enables secure boot for the runtime.' + - name: 'networkTags' + type: Array + item_type: + type: String + description: 'Applies the given Compute Engine tags to the runtime.' + - name: encryptionSpec + type: NestedObject + description: "Customer-managed encryption key spec for the notebook runtime." + properties: + - name: 'kmsKeyName' + type: String + description: 'The Cloud KMS encryption key (customer-managed encryption key) used to protect the runtime.' \ No newline at end of file diff --git a/mmv1/templates/terraform/examples/colab_runtime_template_basic.tf.tmpl b/mmv1/templates/terraform/examples/colab_runtime_template_basic.tf.tmpl index f17f8d8ec073..8c4f258abd02 100644 --- a/mmv1/templates/terraform/examples/colab_runtime_template_basic.tf.tmpl +++ b/mmv1/templates/terraform/examples/colab_runtime_template_basic.tf.tmpl @@ -1,5 +1,14 @@ resource "google_colab_runtime_template" "{{$.PrimaryResourceId}}" { name = "{{index $.Vars "runtime_template_name"}}" - displayName = "Runtime template full" + display_name = "Runtime template basic" location = "us-central1" + + machine_spec { + machine_type = "e2-standard-4" + } + + network_spec { + enable_internet_access = true + } + } \ No newline at end of file diff --git a/mmv1/templates/terraform/examples/colab_runtime_template_full.tf.tmpl b/mmv1/templates/terraform/examples/colab_runtime_template_full.tf.tmpl index f17f8d8ec073..dadcdffd90ee 100644 --- a/mmv1/templates/terraform/examples/colab_runtime_template_full.tf.tmpl +++ b/mmv1/templates/terraform/examples/colab_runtime_template_full.tf.tmpl @@ -1,5 +1,60 @@ -resource "google_colab_runtime_template" "{{$.PrimaryResourceId}}" { - name = "{{index $.Vars "runtime_template_name"}}" - displayName = "Runtime template full" - location = "us-central1" +resource "google_compute_network" "my_network" { + name = "{{index $.Vars "network_name"}}" + auto_create_subnetworks = false +} + +resource "google_compute_subnetwork" "my_subnetwork" { + name = "{{index $.Vars "network_name"}}" + network = google_compute_network.my_network.id + region = "us-central1" + ip_cidr_range = "10.0.1.0/24" +} + +resource "google_compute_address" "static" { + name = "{{index $.Vars "network_name"}}" +} + +resource "google_colab_runtime_template" "default" { + name = "{{index $.Vars "runtime_template_name"}}" + display_name = "Runtime template full" + location = "us-central1" + description = "Full runtime template" + machine_spec { + machine_type = "n1-standard-2" + accelerator_type = "NVIDIA_TESLA_T4" + accelerator_count = "1" + } + + data_persistent_disk_spec { + disk_type = "pd-standard" + disk_size_gb = 200 + } + + network_spec { + enable_internet_access = true + network = google_compute_network.my_network.id + subnetwork = google_compute_subnetwork.my_subnetwork.id + } + + labels = { + k = "val" + } + + idle_shutdown_config { + idle_timeout = "3600s" + } + + euc_config { + euc_disabled = true + } + + shielded_vm_config { + enable_secure_boot = true + } + + network_tags = ["abc", "def"] + + encryption_spec { + kms_key_name = "{{index $.Vars "key_name"}}" + } } \ No newline at end of file From 883aebf62855e5dfd31f664d0db367cdba77f409 Mon Sep 17 00:00:00 2001 From: Bhargav Chereddy Date: Wed, 8 Jan 2025 00:14:24 +0000 Subject: [PATCH 10/28] empty lines --- mmv1/products/colab/product.yaml | 2 +- .../terraform/examples/colab_runtime_template_basic.tf.tmpl | 3 +-- .../terraform/examples/colab_runtime_template_full.tf.tmpl | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/mmv1/products/colab/product.yaml b/mmv1/products/colab/product.yaml index 74ebc92e709a..0d588605b43d 100644 --- a/mmv1/products/colab/product.yaml +++ b/mmv1/products/colab/product.yaml @@ -22,4 +22,4 @@ versions: base_url: 'https://{{region}}-aiplatform.googleapis.com/v1beta1/' cai_base_url: 'https://aiplatform.googleapis.com/v1beta1/' scopes: - - 'https://www.googleapis.com/auth/cloud-platform' \ No newline at end of file + - 'https://www.googleapis.com/auth/cloud-platform' diff --git a/mmv1/templates/terraform/examples/colab_runtime_template_basic.tf.tmpl b/mmv1/templates/terraform/examples/colab_runtime_template_basic.tf.tmpl index 8c4f258abd02..7ffb08187732 100644 --- a/mmv1/templates/terraform/examples/colab_runtime_template_basic.tf.tmpl +++ b/mmv1/templates/terraform/examples/colab_runtime_template_basic.tf.tmpl @@ -10,5 +10,4 @@ resource "google_colab_runtime_template" "{{$.PrimaryResourceId}}" { network_spec { enable_internet_access = true } - -} \ No newline at end of file +} diff --git a/mmv1/templates/terraform/examples/colab_runtime_template_full.tf.tmpl b/mmv1/templates/terraform/examples/colab_runtime_template_full.tf.tmpl index dadcdffd90ee..eeff3bf269f7 100644 --- a/mmv1/templates/terraform/examples/colab_runtime_template_full.tf.tmpl +++ b/mmv1/templates/terraform/examples/colab_runtime_template_full.tf.tmpl @@ -57,4 +57,4 @@ resource "google_colab_runtime_template" "default" { encryption_spec { kms_key_name = "{{index $.Vars "key_name"}}" } -} \ No newline at end of file +} From c195e5c6487793dbd683ec1810d840fbaa35001e Mon Sep 17 00:00:00 2001 From: Bhargav Chereddy Date: Wed, 8 Jan 2025 00:15:30 +0000 Subject: [PATCH 11/28] empty lines --- mmv1/products/colab/RuntimeTemplate.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/products/colab/RuntimeTemplate.yaml b/mmv1/products/colab/RuntimeTemplate.yaml index a5d361ac8b98..a3143a40bbd9 100644 --- a/mmv1/products/colab/RuntimeTemplate.yaml +++ b/mmv1/products/colab/RuntimeTemplate.yaml @@ -176,4 +176,4 @@ properties: properties: - name: 'kmsKeyName' type: String - description: 'The Cloud KMS encryption key (customer-managed encryption key) used to protect the runtime.' \ No newline at end of file + description: 'The Cloud KMS encryption key (customer-managed encryption key) used to protect the runtime.' From 808c8a34dbdefa38a224f44cd0ca39ba7bca3a4e Mon Sep 17 00:00:00 2001 From: Bhargav Chereddy Date: Wed, 8 Jan 2025 00:19:03 +0000 Subject: [PATCH 12/28] lint fixes --- mmv1/products/colab/RuntimeTemplate.yaml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/mmv1/products/colab/RuntimeTemplate.yaml b/mmv1/products/colab/RuntimeTemplate.yaml index a3143a40bbd9..4ca299a12411 100644 --- a/mmv1/products/colab/RuntimeTemplate.yaml +++ b/mmv1/products/colab/RuntimeTemplate.yaml @@ -15,10 +15,10 @@ name: 'RuntimeTemplate' description: | - 'A runtime template is a VM configuration that specifies a machine type and other characteristics of the VM, - as well as common settings such as the network and whether public internet access is enabled. When you create - a runtime, its VM is created according to the specifications of a runtime template.' - + 'A runtime template is a VM configuration that specifies a machine type and other characteristics of the VM, + as well as common settings such as the network and whether public internet access is enabled. When you create + a runtime, its VM is created according to the specifications of a runtime template.' + references: guides: 'Create a runtime template': 'https://cloud.google.com/colab/docs/create-runtime-template' @@ -57,8 +57,7 @@ parameters: required: true immutable: true url_param_only: true - description: | - The location for the resource: https://cloud.google.com/colab/docs/locations + description: 'The location for the resource: https://cloud.google.com/colab/docs/locations' properties: - name: 'name' type: String @@ -108,8 +107,7 @@ properties: properties: - name: 'diskType' type: enum - description: | - The type of the persistent disk. + description: 'The type of the persistent disk.' enum_values: - 'pd-standard' - 'pd-ssd' From aa2f3c6b62424bce953226c4188157047d4408c8 Mon Sep 17 00:00:00 2001 From: Bhargav Chereddy Date: Wed, 8 Jan 2025 01:31:57 +0000 Subject: [PATCH 13/28] formatting --- mmv1/products/colab/RuntimeTemplate.yaml | 36 ++++++++----------- .../examples/workbench_instance_full.tf.tmpl | 12 ------- 2 files changed, 14 insertions(+), 34 deletions(-) diff --git a/mmv1/products/colab/RuntimeTemplate.yaml b/mmv1/products/colab/RuntimeTemplate.yaml index 4ca299a12411..c95542b54ba8 100644 --- a/mmv1/products/colab/RuntimeTemplate.yaml +++ b/mmv1/products/colab/RuntimeTemplate.yaml @@ -50,21 +50,19 @@ examples: project_id: 'PROJECT_NAME' service_account: 'SERVICE_ACCT' test_vars_overrides: - 'key_name': 'acctest.BootstrapKMSKeyInLocation(t, "us-central1").CryptoKey.Name' + key_name: 'acctest.BootstrapKMSKeyInLocation(t, "us-central1").CryptoKey.Name' parameters: - name: 'location' type: String required: true - immutable: true url_param_only: true description: 'The location for the resource: https://cloud.google.com/colab/docs/locations' properties: - name: 'name' type: String - immutable: true url_param_only: true - description: | - 'The resource name of the Runtime Template' + required: true + description: 'The resource name of the Runtime Template' - name: 'displayName' type: String description: @@ -75,16 +73,14 @@ properties: description: 'The description of the Runtime Template.' - name: machineSpec type: NestedObject - default_from_api: true description: | - "The machine configuration of the runtime." + 'The machine configuration of the runtime.' properties: - name: 'machineType' required: true type: string description: | The Compute Engine machine type selected for the runtime. - default_from_api: true - name: 'acceleratorType' type: enum description: | @@ -98,12 +94,11 @@ properties: - name: 'acceleratorCount' type: Integer default_from_api: true - description: | - The number of accelerators used by the runtime. + description: 'The number of accelerators used by the runtime.' - name: dataPersistentDiskSpec type: NestedObject default_from_api: true - description: "The configuration for the data disk of the runtime." + description: 'The configuration for the data disk of the runtime.' properties: - name: 'diskType' type: enum @@ -119,23 +114,20 @@ properties: The disk size of the runtime in GB. If specified, the diskType must also be specified. The minimum size is 10GB and the maximum is 65536GB. - name: networkSpec type: NestedObject - default_from_api: true - description: | - "The network configuration for the runtime." + required: true + description: 'The network configuration for the runtime.' properties: - name: 'enableInternetAccess' type: Boolean description: Enable public internet access for the runtime. Enabled by default. - default_from_api: true - name: 'network' type: String - description: The name of the VPC that this runtime is in. + description: 'The name of the VPC that this runtime is in.' default_from_api: true diff_suppress_func: 'tpgresource.CompareSelfLinkRelativePaths' - name: 'subnetwork' type: String - description: | - The name of the VPC that this runtime is in. + description: 'The name of the VPC that this runtime is in.' default_from_api: true diff_suppress_func: 'tpgresource.CompareSelfLinkRelativePaths' - name: 'labels' @@ -144,21 +136,21 @@ properties: - name: idleShutdownConfig type: NestedObject default_from_api: true - description: "Notebook Idle Shutdown configuration for the runtime." + description: 'Notebook Idle Shutdown configuration for the runtime.' properties: - name: 'idleTimeout' type: String description: 'The duration after which the runtime is automatically shut down. An input of 0s disables the idle shutdown feature, and a valid range is [10m, 24h].' - name: eucConfig type: NestedObject - description: "EUC configuration of the NotebookRuntimeTemplate." + description: 'EUC configuration of the NotebookRuntimeTemplate.' properties: - name: 'eucDisabled' type: Boolean description: 'Enable end user credential access for the runtime.' - name: shieldedVmConfig type: NestedObject - description: "Runtime Shielded VM spec." + description: 'Runtime Shielded VM spec.' properties: - name: 'enableSecureBoot' type: Boolean @@ -170,7 +162,7 @@ properties: description: 'Applies the given Compute Engine tags to the runtime.' - name: encryptionSpec type: NestedObject - description: "Customer-managed encryption key spec for the notebook runtime." + description: 'Customer-managed encryption key spec for the notebook runtime.' properties: - name: 'kmsKeyName' type: String diff --git a/mmv1/templates/terraform/examples/workbench_instance_full.tf.tmpl b/mmv1/templates/terraform/examples/workbench_instance_full.tf.tmpl index 2252af59b8e1..b72ea362eab7 100644 --- a/mmv1/templates/terraform/examples/workbench_instance_full.tf.tmpl +++ b/mmv1/templates/terraform/examples/workbench_instance_full.tf.tmpl @@ -10,18 +10,6 @@ resource "google_compute_subnetwork" "my_subnetwork" { ip_cidr_range = "10.0.1.0/24" } -resource "google_compute_address" "static" { - name = "{{index $.Vars "network_name"}}" -} - -resource "google_service_account_iam_binding" "act_as_permission" { - service_account_id = "projects/{{index $.TestEnvVars "project_id"}}/serviceAccounts/{{index $.TestEnvVars "service_account"}}" - role = "roles/iam.serviceAccountUser" - members = [ - "user:example@example.com", - ] -} - resource "google_workbench_instance" "{{$.PrimaryResourceId}}" { name = "{{index $.Vars "instance_name"}}" location = "us-central1-a" From cb60cca778d391009495c2a13afeee2d6e578ce5 Mon Sep 17 00:00:00 2001 From: Bhargav Chereddy Date: Wed, 8 Jan 2025 18:32:28 +0000 Subject: [PATCH 14/28] undo wrong changes --- .../examples/colab_runtime_template_full.tf.tmpl | 4 ---- .../examples/workbench_instance_full.tf.tmpl | 12 ++++++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/mmv1/templates/terraform/examples/colab_runtime_template_full.tf.tmpl b/mmv1/templates/terraform/examples/colab_runtime_template_full.tf.tmpl index eeff3bf269f7..9c09e7b78fa8 100644 --- a/mmv1/templates/terraform/examples/colab_runtime_template_full.tf.tmpl +++ b/mmv1/templates/terraform/examples/colab_runtime_template_full.tf.tmpl @@ -10,10 +10,6 @@ resource "google_compute_subnetwork" "my_subnetwork" { ip_cidr_range = "10.0.1.0/24" } -resource "google_compute_address" "static" { - name = "{{index $.Vars "network_name"}}" -} - resource "google_colab_runtime_template" "default" { name = "{{index $.Vars "runtime_template_name"}}" display_name = "Runtime template full" diff --git a/mmv1/templates/terraform/examples/workbench_instance_full.tf.tmpl b/mmv1/templates/terraform/examples/workbench_instance_full.tf.tmpl index b72ea362eab7..2252af59b8e1 100644 --- a/mmv1/templates/terraform/examples/workbench_instance_full.tf.tmpl +++ b/mmv1/templates/terraform/examples/workbench_instance_full.tf.tmpl @@ -10,6 +10,18 @@ resource "google_compute_subnetwork" "my_subnetwork" { ip_cidr_range = "10.0.1.0/24" } +resource "google_compute_address" "static" { + name = "{{index $.Vars "network_name"}}" +} + +resource "google_service_account_iam_binding" "act_as_permission" { + service_account_id = "projects/{{index $.TestEnvVars "project_id"}}/serviceAccounts/{{index $.TestEnvVars "service_account"}}" + role = "roles/iam.serviceAccountUser" + members = [ + "user:example@example.com", + ] +} + resource "google_workbench_instance" "{{$.PrimaryResourceId}}" { name = "{{index $.Vars "instance_name"}}" location = "us-central1-a" From 206748b72ec2830ab5003af1b343cbfea275b2f0 Mon Sep 17 00:00:00 2001 From: Bhargav Chereddy Date: Wed, 8 Jan 2025 19:37:25 +0000 Subject: [PATCH 15/28] fix colab test --- .../terraform/examples/colab_runtime_template_full.tf.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/templates/terraform/examples/colab_runtime_template_full.tf.tmpl b/mmv1/templates/terraform/examples/colab_runtime_template_full.tf.tmpl index 9c09e7b78fa8..3078041236d9 100644 --- a/mmv1/templates/terraform/examples/colab_runtime_template_full.tf.tmpl +++ b/mmv1/templates/terraform/examples/colab_runtime_template_full.tf.tmpl @@ -10,7 +10,7 @@ resource "google_compute_subnetwork" "my_subnetwork" { ip_cidr_range = "10.0.1.0/24" } -resource "google_colab_runtime_template" "default" { +resource "google_colab_runtime_template" "{{$.PrimaryResourceId}}" { name = "{{index $.Vars "runtime_template_name"}}" display_name = "Runtime template full" location = "us-central1" From 01d38f39e626630ba19b8fce19b6b8ef394ebaee Mon Sep 17 00:00:00 2001 From: Bhargav Chereddy Date: Wed, 8 Jan 2025 19:42:48 +0000 Subject: [PATCH 16/28] fix teamcity tests --- .../terraform/.teamcity/components/inputs/services_beta.kt | 5 +++++ .../terraform/.teamcity/components/inputs/services_ga.kt | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt b/mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt index 24abf96b5b4f..6f570a3f2e42 100644 --- a/mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt +++ b/mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt @@ -216,6 +216,11 @@ var ServicesListBeta = mapOf( "displayName" to "Cloudtasks", "path" to "./google-beta/services/cloudtasks" ), + "colab" to mapOf( + "name" to "colab", + "displayName" to "Colab", + "path" to "./google-beta/services/colab" + ), "composer" to mapOf( "name" to "composer", "displayName" to "Composer", diff --git a/mmv1/third_party/terraform/.teamcity/components/inputs/services_ga.kt b/mmv1/third_party/terraform/.teamcity/components/inputs/services_ga.kt index a5bb12bca8f1..5acb4430314c 100644 --- a/mmv1/third_party/terraform/.teamcity/components/inputs/services_ga.kt +++ b/mmv1/third_party/terraform/.teamcity/components/inputs/services_ga.kt @@ -216,6 +216,11 @@ var ServicesListGa = mapOf( "displayName" to "Cloudtasks", "path" to "./google/services/cloudtasks" ), + "colab" to mapOf( + "name" to "colab", + "displayName" to "Colab", + "path" to "./google/services/colab" + ), "composer" to mapOf( "name" to "composer", "displayName" to "Composer", From 28d57e14ccf068ac40a432d3bc9a40f4fa5da4b5 Mon Sep 17 00:00:00 2001 From: Bhargav Chereddy Date: Wed, 8 Jan 2025 20:28:46 +0000 Subject: [PATCH 17/28] keep TF consistent with API --- mmv1/products/colab/RuntimeTemplate.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/mmv1/products/colab/RuntimeTemplate.yaml b/mmv1/products/colab/RuntimeTemplate.yaml index c95542b54ba8..5cdbd2ebe217 100644 --- a/mmv1/products/colab/RuntimeTemplate.yaml +++ b/mmv1/products/colab/RuntimeTemplate.yaml @@ -61,7 +61,6 @@ properties: - name: 'name' type: String url_param_only: true - required: true description: 'The resource name of the Runtime Template' - name: 'displayName' type: String @@ -77,7 +76,6 @@ properties: 'The machine configuration of the runtime.' properties: - name: 'machineType' - required: true type: string description: | The Compute Engine machine type selected for the runtime. @@ -114,7 +112,6 @@ properties: The disk size of the runtime in GB. If specified, the diskType must also be specified. The minimum size is 10GB and the maximum is 65536GB. - name: networkSpec type: NestedObject - required: true description: 'The network configuration for the runtime.' properties: - name: 'enableInternetAccess' From 78bfb4b6a0be4a19e621224ab826508633f490a1 Mon Sep 17 00:00:00 2001 From: Bhargav Chereddy Date: Thu, 9 Jan 2025 00:26:04 +0000 Subject: [PATCH 18/28] Move name to parameters --- mmv1/products/colab/RuntimeTemplate.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/products/colab/RuntimeTemplate.yaml b/mmv1/products/colab/RuntimeTemplate.yaml index 5cdbd2ebe217..1b2ab37145ef 100644 --- a/mmv1/products/colab/RuntimeTemplate.yaml +++ b/mmv1/products/colab/RuntimeTemplate.yaml @@ -57,11 +57,11 @@ parameters: required: true url_param_only: true description: 'The location for the resource: https://cloud.google.com/colab/docs/locations' -properties: - name: 'name' type: String url_param_only: true description: 'The resource name of the Runtime Template' +properties: - name: 'displayName' type: String description: From 1eb0c285e02eb6560da982be763a072fcf968cab Mon Sep 17 00:00:00 2001 From: Bhargav Chereddy Date: Thu, 9 Jan 2025 00:46:25 +0000 Subject: [PATCH 19/28] remove unnecessary variables --- mmv1/products/colab/RuntimeTemplate.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/mmv1/products/colab/RuntimeTemplate.yaml b/mmv1/products/colab/RuntimeTemplate.yaml index 1b2ab37145ef..37eb5234d3ba 100644 --- a/mmv1/products/colab/RuntimeTemplate.yaml +++ b/mmv1/products/colab/RuntimeTemplate.yaml @@ -48,7 +48,6 @@ examples: key_name: 'my-crypto-key' test_env_vars: project_id: 'PROJECT_NAME' - service_account: 'SERVICE_ACCT' test_vars_overrides: key_name: 'acctest.BootstrapKMSKeyInLocation(t, "us-central1").CryptoKey.Name' parameters: From beb9849bdcf2e4ee9bf4f2a31b6345b9c9893df4 Mon Sep 17 00:00:00 2001 From: Bhargav Chereddy Date: Thu, 9 Jan 2025 02:15:55 +0000 Subject: [PATCH 20/28] Another unused var --- mmv1/products/colab/RuntimeTemplate.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/mmv1/products/colab/RuntimeTemplate.yaml b/mmv1/products/colab/RuntimeTemplate.yaml index 37eb5234d3ba..f381192d3452 100644 --- a/mmv1/products/colab/RuntimeTemplate.yaml +++ b/mmv1/products/colab/RuntimeTemplate.yaml @@ -46,8 +46,6 @@ examples: runtime_template_name: 'colab-runtime-template' network_name: 'colab-test-default' key_name: 'my-crypto-key' - test_env_vars: - project_id: 'PROJECT_NAME' test_vars_overrides: key_name: 'acctest.BootstrapKMSKeyInLocation(t, "us-central1").CryptoKey.Name' parameters: From 90a9a24e82831a4fe00d6bad8b7e5b3f5c8b9c4b Mon Sep 17 00:00:00 2001 From: Bhargav Chereddy Date: Thu, 9 Jan 2025 20:40:02 +0000 Subject: [PATCH 21/28] Add no name test --- mmv1/products/colab/RuntimeTemplate.yaml | 5 +++++ .../examples/colab_runtime_template_no_name.tf.tmpl | 12 ++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 mmv1/templates/terraform/examples/colab_runtime_template_no_name.tf.tmpl diff --git a/mmv1/products/colab/RuntimeTemplate.yaml b/mmv1/products/colab/RuntimeTemplate.yaml index f381192d3452..08f71b4c9e12 100644 --- a/mmv1/products/colab/RuntimeTemplate.yaml +++ b/mmv1/products/colab/RuntimeTemplate.yaml @@ -38,6 +38,10 @@ examples: region_override: 'us-central1' vars: runtime_template_name: 'colab-runtime-template' + - name: 'colab_runtime_template_no_name' + primary_resource_id: 'runtime-template' + region_override: 'us-central1' + exclude_import_test: true - name: 'colab_runtime_template_full' primary_resource_id: 'runtime-template' primary_resource_name: 'fmt.Sprintf("tf-test-colab-runtime-template%s", context["random_suffix"])' @@ -57,6 +61,7 @@ parameters: - name: 'name' type: String url_param_only: true + default_from_api: true description: 'The resource name of the Runtime Template' properties: - name: 'displayName' diff --git a/mmv1/templates/terraform/examples/colab_runtime_template_no_name.tf.tmpl b/mmv1/templates/terraform/examples/colab_runtime_template_no_name.tf.tmpl new file mode 100644 index 000000000000..51dff7ab02cc --- /dev/null +++ b/mmv1/templates/terraform/examples/colab_runtime_template_no_name.tf.tmpl @@ -0,0 +1,12 @@ +resource "google_colab_runtime_template" "{{$.PrimaryResourceId}}" { + display_name = "Runtime template no name" + location = "us-central1" + + machine_spec { + machine_type = "e2-standard-4" + } + + network_spec { + enable_internet_access = true + } +} From 2f4a67c0d9350f972d29e641a23c9d11b23575b7 Mon Sep 17 00:00:00 2001 From: Bhargav Chereddy Date: Thu, 9 Jan 2025 22:22:22 +0000 Subject: [PATCH 22/28] Added default_from_api to necessary fields --- mmv1/products/colab/RuntimeTemplate.yaml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mmv1/products/colab/RuntimeTemplate.yaml b/mmv1/products/colab/RuntimeTemplate.yaml index 08f71b4c9e12..256a47481a68 100644 --- a/mmv1/products/colab/RuntimeTemplate.yaml +++ b/mmv1/products/colab/RuntimeTemplate.yaml @@ -74,6 +74,7 @@ properties: description: 'The description of the Runtime Template.' - name: machineSpec type: NestedObject + default_from_api: true description: | 'The machine configuration of the runtime.' properties: @@ -93,7 +94,6 @@ properties: - 'NVIDIA_L4' - name: 'acceleratorCount' type: Integer - default_from_api: true description: 'The number of accelerators used by the runtime.' - name: dataPersistentDiskSpec type: NestedObject @@ -114,6 +114,7 @@ properties: The disk size of the runtime in GB. If specified, the diskType must also be specified. The minimum size is 10GB and the maximum is 65536GB. - name: networkSpec type: NestedObject + default_from_api: true description: 'The network configuration for the runtime.' properties: - name: 'enableInternetAccess' @@ -122,12 +123,10 @@ properties: - name: 'network' type: String description: 'The name of the VPC that this runtime is in.' - default_from_api: true diff_suppress_func: 'tpgresource.CompareSelfLinkRelativePaths' - name: 'subnetwork' type: String - description: 'The name of the VPC that this runtime is in.' - default_from_api: true + description: 'The name of the subnetwork that this runtime is in.' diff_suppress_func: 'tpgresource.CompareSelfLinkRelativePaths' - name: 'labels' type: KeyValueLabels @@ -146,7 +145,7 @@ properties: properties: - name: 'eucDisabled' type: Boolean - description: 'Enable end user credential access for the runtime.' + description: 'Disable end user credential access for the runtime.' - name: shieldedVmConfig type: NestedObject description: 'Runtime Shielded VM spec.' From 7b919dbf3787b5e03ee303cef6157d0a0955b105 Mon Sep 17 00:00:00 2001 From: Bhargav Chereddy Date: Fri, 10 Jan 2025 01:12:27 +0000 Subject: [PATCH 23/28] Add IAM --- mmv1/products/colab/RuntimeTemplate.yaml | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/mmv1/products/colab/RuntimeTemplate.yaml b/mmv1/products/colab/RuntimeTemplate.yaml index 256a47481a68..57af3327635f 100644 --- a/mmv1/products/colab/RuntimeTemplate.yaml +++ b/mmv1/products/colab/RuntimeTemplate.yaml @@ -31,21 +31,25 @@ autogen_async: true async: operation: base_url: '{{op_id}}' +iam_policy: + parent_resource_attribute: 'runtime_template' + method_name_separator: ':' + fetch_iam_policy_verb: 'POST' + import_format: + - 'projects/{{project}}/locations/{{location}}/notebookRuntimeTemplates/{{runtime_template}}' + - '{{runtime_template}}' examples: - name: 'colab_runtime_template_basic' primary_resource_id: 'runtime-template' primary_resource_name: 'fmt.Sprintf("tf-test-colab-runtime-template%s", context["random_suffix"])' - region_override: 'us-central1' vars: runtime_template_name: 'colab-runtime-template' - name: 'colab_runtime_template_no_name' primary_resource_id: 'runtime-template' - region_override: 'us-central1' exclude_import_test: true - name: 'colab_runtime_template_full' primary_resource_id: 'runtime-template' primary_resource_name: 'fmt.Sprintf("tf-test-colab-runtime-template%s", context["random_suffix"])' - region_override: 'us-central1' vars: runtime_template_name: 'colab-runtime-template' network_name: 'colab-test-default' @@ -60,8 +64,8 @@ parameters: description: 'The location for the resource: https://cloud.google.com/colab/docs/locations' - name: 'name' type: String - url_param_only: true default_from_api: true + url_param_only: true description: 'The resource name of the Runtime Template' properties: - name: 'displayName' @@ -80,6 +84,7 @@ properties: properties: - name: 'machineType' type: string + default_from_api: true description: | The Compute Engine machine type selected for the runtime. - name: 'acceleratorType' @@ -94,15 +99,17 @@ properties: - 'NVIDIA_L4' - name: 'acceleratorCount' type: Integer + default_from_api: true description: 'The number of accelerators used by the runtime.' - name: dataPersistentDiskSpec - type: NestedObject default_from_api: true + type: NestedObject description: 'The configuration for the data disk of the runtime.' properties: - name: 'diskType' type: enum description: 'The type of the persistent disk.' + default_from_api: true enum_values: - 'pd-standard' - 'pd-ssd' @@ -110,6 +117,7 @@ properties: - 'pd-extreme' - name: 'diskSizeGb' type: int + default_from_api: true description: | The disk size of the runtime in GB. If specified, the diskType must also be specified. The minimum size is 10GB and the maximum is 65536GB. - name: networkSpec @@ -119,8 +127,9 @@ properties: properties: - name: 'enableInternetAccess' type: Boolean - description: Enable public internet access for the runtime. Enabled by default. + description: Enable public internet access for the runtime. - name: 'network' + default_from_api: true type: String description: 'The name of the VPC that this runtime is in.' diff_suppress_func: 'tpgresource.CompareSelfLinkRelativePaths' @@ -137,6 +146,7 @@ properties: description: 'Notebook Idle Shutdown configuration for the runtime.' properties: - name: 'idleTimeout' + default_from_api: true type: String description: 'The duration after which the runtime is automatically shut down. An input of 0s disables the idle shutdown feature, and a valid range is [10m, 24h].' - name: eucConfig From d582945a68fdb025e1f93667b864e652ba2df7dc Mon Sep 17 00:00:00 2001 From: Bhargav Chereddy Date: Fri, 10 Jan 2025 19:37:59 +0000 Subject: [PATCH 24/28] Add post_create --- mmv1/products/colab/RuntimeTemplate.yaml | 5 +++-- .../terraform/post_create/colab_runtime_template.tmpl | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 mmv1/templates/terraform/post_create/colab_runtime_template.tmpl diff --git a/mmv1/products/colab/RuntimeTemplate.yaml b/mmv1/products/colab/RuntimeTemplate.yaml index 57af3327635f..f6431d2b0721 100644 --- a/mmv1/products/colab/RuntimeTemplate.yaml +++ b/mmv1/products/colab/RuntimeTemplate.yaml @@ -38,6 +38,8 @@ iam_policy: import_format: - 'projects/{{project}}/locations/{{location}}/notebookRuntimeTemplates/{{runtime_template}}' - '{{runtime_template}}' +custom_code: + post_create: 'templates/terraform/post_create/accesspolicy.tmpl' examples: - name: 'colab_runtime_template_basic' primary_resource_id: 'runtime-template' @@ -62,12 +64,11 @@ parameters: required: true url_param_only: true description: 'The location for the resource: https://cloud.google.com/colab/docs/locations' +properties: - name: 'name' type: String default_from_api: true - url_param_only: true description: 'The resource name of the Runtime Template' -properties: - name: 'displayName' type: String description: diff --git a/mmv1/templates/terraform/post_create/colab_runtime_template.tmpl b/mmv1/templates/terraform/post_create/colab_runtime_template.tmpl new file mode 100644 index 000000000000..b6590cdf11cb --- /dev/null +++ b/mmv1/templates/terraform/post_create/colab_runtime_template.tmpl @@ -0,0 +1,11 @@ +// The operation for this resource contains the generated name that we need +// in order to perform a READ. We need to access the object inside of it as +// a map[string]interface, so let's do that. + +resp := res["response"].(map[string]interface{}) +name := tpgresource.GetResourceNameFromSelfLink(resp["name"].(string)) +log.Printf("[DEBUG] Setting AccessPolicy name, id to %s", name) +if err := d.Set("name", name); err != nil { + return fmt.Errorf("Error setting name: %s", err) +} +d.SetId(name) From 464e47bb9dd145dc631793421d950651e2f8f5b9 Mon Sep 17 00:00:00 2001 From: Bhargav Chereddy Date: Sat, 11 Jan 2025 00:01:14 +0000 Subject: [PATCH 25/28] use access policy --- mmv1/products/colab/RuntimeTemplate.yaml | 1 + .../templates/terraform/post_create/accesspolicy.tmpl | 4 ++-- .../terraform/post_create/colab_runtime_template.tmpl | 11 ----------- 3 files changed, 3 insertions(+), 13 deletions(-) delete mode 100644 mmv1/templates/terraform/post_create/colab_runtime_template.tmpl diff --git a/mmv1/products/colab/RuntimeTemplate.yaml b/mmv1/products/colab/RuntimeTemplate.yaml index f6431d2b0721..ab5a6f71ff50 100644 --- a/mmv1/products/colab/RuntimeTemplate.yaml +++ b/mmv1/products/colab/RuntimeTemplate.yaml @@ -68,6 +68,7 @@ properties: - name: 'name' type: String default_from_api: true + custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.tmpl' description: 'The resource name of the Runtime Template' - name: 'displayName' type: String diff --git a/mmv1/templates/terraform/post_create/accesspolicy.tmpl b/mmv1/templates/terraform/post_create/accesspolicy.tmpl index b6590cdf11cb..3eee2620770f 100644 --- a/mmv1/templates/terraform/post_create/accesspolicy.tmpl +++ b/mmv1/templates/terraform/post_create/accesspolicy.tmpl @@ -4,8 +4,8 @@ resp := res["response"].(map[string]interface{}) name := tpgresource.GetResourceNameFromSelfLink(resp["name"].(string)) -log.Printf("[DEBUG] Setting AccessPolicy name, id to %s", name) +log.Printf("[DEBUG] Setting resource name, id to %s", name) if err := d.Set("name", name); err != nil { return fmt.Errorf("Error setting name: %s", err) } -d.SetId(name) +d.SetId(name) \ No newline at end of file diff --git a/mmv1/templates/terraform/post_create/colab_runtime_template.tmpl b/mmv1/templates/terraform/post_create/colab_runtime_template.tmpl deleted file mode 100644 index b6590cdf11cb..000000000000 --- a/mmv1/templates/terraform/post_create/colab_runtime_template.tmpl +++ /dev/null @@ -1,11 +0,0 @@ -// The operation for this resource contains the generated name that we need -// in order to perform a READ. We need to access the object inside of it as -// a map[string]interface, so let's do that. - -resp := res["response"].(map[string]interface{}) -name := tpgresource.GetResourceNameFromSelfLink(resp["name"].(string)) -log.Printf("[DEBUG] Setting AccessPolicy name, id to %s", name) -if err := d.Set("name", name); err != nil { - return fmt.Errorf("Error setting name: %s", err) -} -d.SetId(name) From 8053cbd03e56bbf888234fecaa23c904437bb62a Mon Sep 17 00:00:00 2001 From: Bhargav Chereddy Date: Sat, 11 Jan 2025 00:17:57 +0000 Subject: [PATCH 26/28] Add a post create --- mmv1/products/colab/RuntimeTemplate.yaml | 2 +- mmv1/templates/terraform/post_create/accesspolicy.tmpl | 2 +- .../terraform/post_create/colab_runtime_template.tmpl | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 mmv1/templates/terraform/post_create/colab_runtime_template.tmpl diff --git a/mmv1/products/colab/RuntimeTemplate.yaml b/mmv1/products/colab/RuntimeTemplate.yaml index ab5a6f71ff50..e88cc8d4cbbd 100644 --- a/mmv1/products/colab/RuntimeTemplate.yaml +++ b/mmv1/products/colab/RuntimeTemplate.yaml @@ -39,7 +39,7 @@ iam_policy: - 'projects/{{project}}/locations/{{location}}/notebookRuntimeTemplates/{{runtime_template}}' - '{{runtime_template}}' custom_code: - post_create: 'templates/terraform/post_create/accesspolicy.tmpl' + post_create: 'templates/terraform/post_create/colab_runtime_template.tmpl' examples: - name: 'colab_runtime_template_basic' primary_resource_id: 'runtime-template' diff --git a/mmv1/templates/terraform/post_create/accesspolicy.tmpl b/mmv1/templates/terraform/post_create/accesspolicy.tmpl index 3eee2620770f..84bad5bef8e8 100644 --- a/mmv1/templates/terraform/post_create/accesspolicy.tmpl +++ b/mmv1/templates/terraform/post_create/accesspolicy.tmpl @@ -4,7 +4,7 @@ resp := res["response"].(map[string]interface{}) name := tpgresource.GetResourceNameFromSelfLink(resp["name"].(string)) -log.Printf("[DEBUG] Setting resource name, id to %s", name) +log.Printf("[DEBUG] Setting AccessPolicy name, id to %s", name) if err := d.Set("name", name); err != nil { return fmt.Errorf("Error setting name: %s", err) } diff --git a/mmv1/templates/terraform/post_create/colab_runtime_template.tmpl b/mmv1/templates/terraform/post_create/colab_runtime_template.tmpl new file mode 100644 index 000000000000..61b91dfd180c --- /dev/null +++ b/mmv1/templates/terraform/post_create/colab_runtime_template.tmpl @@ -0,0 +1,10 @@ +// The operation for this resource contains the generated name that we need +// in order to perform a READ. We need to access the object inside of it as +// a map[string]interface, so let's do that. + +resp := res["response"].(map[string]interface{}) +name := tpgresource.GetResourceNameFromSelfLink(resp["name"].(string)) +log.Printf("[DEBUG] Setting resource name, id to %s", name) +if err := d.Set("name", name); err != nil { + return fmt.Errorf("Error setting name: %s", err) +} \ No newline at end of file From 871e4d6330c67bba6df099d6b488c1085c439446 Mon Sep 17 00:00:00 2001 From: Bhargav Chereddy Date: Sat, 11 Jan 2025 00:25:36 +0000 Subject: [PATCH 27/28] empty lines --- mmv1/templates/terraform/post_create/accesspolicy.tmpl | 2 +- .../templates/terraform/post_create/colab_runtime_template.tmpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mmv1/templates/terraform/post_create/accesspolicy.tmpl b/mmv1/templates/terraform/post_create/accesspolicy.tmpl index 84bad5bef8e8..b6590cdf11cb 100644 --- a/mmv1/templates/terraform/post_create/accesspolicy.tmpl +++ b/mmv1/templates/terraform/post_create/accesspolicy.tmpl @@ -8,4 +8,4 @@ log.Printf("[DEBUG] Setting AccessPolicy name, id to %s", name) if err := d.Set("name", name); err != nil { return fmt.Errorf("Error setting name: %s", err) } -d.SetId(name) \ No newline at end of file +d.SetId(name) diff --git a/mmv1/templates/terraform/post_create/colab_runtime_template.tmpl b/mmv1/templates/terraform/post_create/colab_runtime_template.tmpl index 61b91dfd180c..c959ee745e0b 100644 --- a/mmv1/templates/terraform/post_create/colab_runtime_template.tmpl +++ b/mmv1/templates/terraform/post_create/colab_runtime_template.tmpl @@ -7,4 +7,4 @@ name := tpgresource.GetResourceNameFromSelfLink(resp["name"].(string)) log.Printf("[DEBUG] Setting resource name, id to %s", name) if err := d.Set("name", name); err != nil { return fmt.Errorf("Error setting name: %s", err) -} \ No newline at end of file +} From e8c87fb46ccac0e7271808ff253551ec1c23c23f Mon Sep 17 00:00:00 2001 From: Bhargav Chereddy Date: Mon, 13 Jan 2025 04:36:35 +0000 Subject: [PATCH 28/28] Remove IAM --- mmv1/products/colab/RuntimeTemplate.yaml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/mmv1/products/colab/RuntimeTemplate.yaml b/mmv1/products/colab/RuntimeTemplate.yaml index e88cc8d4cbbd..3919c18e21dc 100644 --- a/mmv1/products/colab/RuntimeTemplate.yaml +++ b/mmv1/products/colab/RuntimeTemplate.yaml @@ -31,13 +31,6 @@ autogen_async: true async: operation: base_url: '{{op_id}}' -iam_policy: - parent_resource_attribute: 'runtime_template' - method_name_separator: ':' - fetch_iam_policy_verb: 'POST' - import_format: - - 'projects/{{project}}/locations/{{location}}/notebookRuntimeTemplates/{{runtime_template}}' - - '{{runtime_template}}' custom_code: post_create: 'templates/terraform/post_create/colab_runtime_template.tmpl' examples: