diff --git a/mmv1/products/colab/RuntimeTemplate.yaml b/mmv1/products/colab/RuntimeTemplate.yaml new file mode 100644 index 000000000000..3919c18e21dc --- /dev/null +++ b/mmv1/products/colab/RuntimeTemplate.yaml @@ -0,0 +1,172 @@ +# 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?notebook_runtime_template_id={{name}}' +autogen_async: true +async: + operation: + base_url: '{{op_id}}' +custom_code: + post_create: 'templates/terraform/post_create/colab_runtime_template.tmpl' +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"])' + vars: + runtime_template_name: 'colab-runtime-template' + - name: 'colab_runtime_template_no_name' + primary_resource_id: 'runtime-template' + 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"])' + vars: + runtime_template_name: 'colab-runtime-template' + network_name: 'colab-test-default' + key_name: 'my-crypto-key' + test_vars_overrides: + key_name: 'acctest.BootstrapKMSKeyInLocation(t, "us-central1").CryptoKey.Name' +parameters: + - name: 'location' + type: String + 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 + custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.tmpl' + description: 'The resource name of the Runtime Template' + - name: 'displayName' + type: String + description: + Required. The display name of the Runtime Template. + required: true + - name: description + type: String + description: 'The description of the Runtime Template.' + - name: machineSpec + type: NestedObject + default_from_api: true + description: | + 'The machine configuration of the runtime.' + properties: + - name: 'machineType' + type: string + default_from_api: true + description: | + The Compute Engine machine type selected for the runtime. + - 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: Integer + default_from_api: true + description: 'The number of accelerators used by the runtime.' + - name: dataPersistentDiskSpec + 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' + - 'pd-balanced' + - '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 + 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. + - name: 'network' + default_from_api: true + type: String + description: 'The name of the VPC that this runtime is in.' + diff_suppress_func: 'tpgresource.CompareSelfLinkRelativePaths' + - name: 'subnetwork' + type: String + description: 'The name of the subnetwork that this runtime is in.' + 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' + 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 + type: NestedObject + description: 'EUC configuration of the NotebookRuntimeTemplate.' + properties: + - name: 'eucDisabled' + type: Boolean + description: 'Disable 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.' diff --git a/mmv1/products/colab/product.yaml b/mmv1/products/colab/product.yaml new file mode 100644 index 000000000000..0d588605b43d --- /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' 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..7ffb08187732 --- /dev/null +++ b/mmv1/templates/terraform/examples/colab_runtime_template_basic.tf.tmpl @@ -0,0 +1,13 @@ +resource "google_colab_runtime_template" "{{$.PrimaryResourceId}}" { + name = "{{index $.Vars "runtime_template_name"}}" + display_name = "Runtime template basic" + location = "us-central1" + + machine_spec { + machine_type = "e2-standard-4" + } + + network_spec { + enable_internet_access = true + } +} 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..3078041236d9 --- /dev/null +++ b/mmv1/templates/terraform/examples/colab_runtime_template_full.tf.tmpl @@ -0,0 +1,56 @@ +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_colab_runtime_template" "{{$.PrimaryResourceId}}" { + 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"}}" + } +} 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 + } +} 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..c959ee745e0b --- /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) +} 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",