Skip to content

Commit 13d0cef

Browse files
feat(compute): add terraform sample for cross-zone repair functionality of rmig
1 parent 7336705 commit 13d0cef

File tree

1 file changed

+81
-0
lines changed
  • compute/rmig_cross_zone_repair

1 file changed

+81
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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+
/**
18+
* Made to resemble:
19+
* gcloud beta compute instance-groups managed create czr-rmig \
20+
* --region us-central1 \
21+
* --size 3 \
22+
* --template example-template \
23+
* --target-distribution-shape balanced \
24+
* --instance-redistribution-type none \
25+
* --default-action-on-vm-failure=repair \
26+
* --on-repair-allow-changing-zone=YES \
27+
* --force-update-on-repair
28+
*/
29+
30+
terraform {
31+
required_providers {
32+
google = {
33+
source = "hashicorp/google-beta"
34+
version = ">= 7.8.0"
35+
}
36+
}
37+
}
38+
39+
# [START compute_rmig_cross_zone_repair_parent_tag]
40+
resource "google_compute_instance_template" "default" {
41+
name = "example-template"
42+
machine_type = "n2-standard-2"
43+
disk {
44+
source_image = "debian-cloud/debian-12"
45+
}
46+
network_interface {
47+
network = "default"
48+
}
49+
}
50+
51+
# [START compute_rmig_cross_zone_repair]
52+
resource "google_compute_region_instance_group_manager" "default" {
53+
name = "czr-rmig"
54+
base_instance_name = "tf-test-czr-rmig"
55+
region = "us-central1"
56+
57+
target_size = 3
58+
distribution_policy_target_shape = "BALANCED"
59+
60+
version {
61+
instance_template = google_compute_instance_template.default.id
62+
}
63+
64+
instance_lifecycle_policy {
65+
default_action_on_failure = "REPAIR"
66+
force_update_on_repair = "YES"
67+
on_repair{
68+
allow_changing_zone = "YES"
69+
}
70+
}
71+
72+
update_policy {
73+
instance_redistribution_type = "NONE"
74+
type = "OPPORTUNISTIC"
75+
minimal_action = "REPLACE"
76+
max_surge_fixed = 0
77+
max_unavailable_fixed = 6
78+
}
79+
}
80+
# [END compute_rmig_cross_zone_repair]
81+
# [END compute_rmig_cross_zone_repair_parent_tag]

0 commit comments

Comments
 (0)