|
| 1 | +/** |
| 2 | + * Copyright 2024 Google LLC |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +/** |
| 17 | + * Made to resemble: |
| 18 | + * gcloud compute instance-groups managed resize-requests create igm \ |
| 19 | + * --resize-request=rr \ |
| 20 | + * --resize-by=3 \ |
| 21 | + * --requested-run-duration=1800 \ |
| 22 | + * --zone=europe-west4-a |
| 23 | + */ |
| 24 | + |
| 25 | +# [START compute_resize_request_basic_parent_tag] |
| 26 | +resource "google_compute_instance_template" "default" { |
| 27 | + machine_type = "a2-ultragpu-8g" |
| 28 | + |
| 29 | + disk { |
| 30 | + source_image = "debian-cloud/debian-11" |
| 31 | + } |
| 32 | + |
| 33 | + network_interface { |
| 34 | + network = "default" |
| 35 | + } |
| 36 | + scheduling { |
| 37 | + on_host_maintenance = "TERMINATE" |
| 38 | + } |
| 39 | + reservation_affinity { |
| 40 | + type = "NO_RESERVATION" |
| 41 | + } |
| 42 | +} |
| 43 | + |
| 44 | +resource "google_compute_instance_group_manager" "default" { |
| 45 | + name = "igm" |
| 46 | + base_instance_name = "test" |
| 47 | + zone = "europe-west4-a" |
| 48 | + |
| 49 | + version { |
| 50 | + instance_template = google_compute_instance_template.default.id |
| 51 | + name = "primary" |
| 52 | + } |
| 53 | + instance_lifecycle_policy { |
| 54 | + default_action_on_failure = "DO_NOTHING" |
| 55 | + } |
| 56 | +} |
| 57 | + |
| 58 | +# [START compute_resize_request_basic_tag] |
| 59 | +resource "google_compute_resize_request" "default" { |
| 60 | + provider = google-beta |
| 61 | + instance_group_manager = google_compute_instance_group_manager.default.name |
| 62 | + zone = google_compute_instance_group_manager.default.zone |
| 63 | + name = "rr" |
| 64 | + resize_by = 3 |
| 65 | + requested_run_duration { |
| 66 | + seconds = 1800 |
| 67 | + } |
| 68 | +} |
| 69 | +# [END compute_resize_request_basic_tag] |
| 70 | +# [END compute_resize_request_basic_parent_tag] |
0 commit comments