|
| 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 update standby-mig \ |
| 19 | + * --standby-policy-mode=scale-out-pool \ |
| 20 | + * --standby-policy-initial-delay=50 \ |
| 21 | + * --target-size=2 \ |
| 22 | + * --suspended-size=1 \ |
| 23 | + * --stopped-size=2 \ |
| 24 | + * --zone=us-central1-f |
| 25 | + */ |
| 26 | + |
| 27 | +terraform { |
| 28 | + required_providers { |
| 29 | + google = { |
| 30 | + source = "hashicorp/google" |
| 31 | + version = ">= 6.16.0" |
| 32 | + } |
| 33 | + } |
| 34 | +} |
| 35 | + |
| 36 | +# [START compute_zonal_mig_standby_policy_with_resize_parent_tag] |
| 37 | +resource "google_compute_instance_template" "default" { |
| 38 | + name = "standby-mig-instance-template" |
| 39 | + machine_type = "e2-medium" |
| 40 | + |
| 41 | + disk { |
| 42 | + source_image = "debian-cloud/debian-11" |
| 43 | + } |
| 44 | + |
| 45 | + network_interface { |
| 46 | + network = "default" |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +# [START compute_zonal_mig_standby_policy_with_resize_tag] |
| 51 | +resource "google_compute_instance_group_manager" "default" { |
| 52 | + name = "standby-mig" |
| 53 | + base_instance_name = "test" |
| 54 | + target_size = 2 |
| 55 | + target_suspended_size = 1 |
| 56 | + target_stopped_size = 2 |
| 57 | + zone = "us-central1-f" |
| 58 | + |
| 59 | + version { |
| 60 | + instance_template = google_compute_instance_template.default.id |
| 61 | + name = "primary" |
| 62 | + } |
| 63 | + standby_policy { |
| 64 | + initial_delay_sec = 50 |
| 65 | + mode = "SCALE_OUT_POOL" |
| 66 | + } |
| 67 | +} |
| 68 | +# [END compute_zonal_mig_standby_policy_with_resize_tag] |
| 69 | +# [END compute_zonal_mig_standby_policy_with_resize_parent_tag] |
0 commit comments