Skip to content

Commit 21d0eeb

Browse files
Add terraform sample for InstanceFlexibilityPolicy of RMIG
1 parent 6e0a556 commit 21d0eeb

File tree

1 file changed

+79
-0
lines changed
  • compute/rmig_instance_flexibility_policy

1 file changed

+79
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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 alpha compute instance-groups managed create flex-igm --project=$PROJECT --region=us-central1 \
20+
* --target-distribution-shape=any-single-zone --instance-redistribution-type NONE \
21+
* --template example-template --size 3 \
22+
* --instance-selection "rank=1,name=best-choice,machine-type=n1-standard-1,n1-standard-2" \
23+
* --instance-selection "rank=2,name=still-ok,machine-type=n2-standard-1" \
24+
* --instance-selection "rank=3,name=if-nothing-else,machine-type=e2-standard-2"
25+
*/
26+
27+
# [START compute_region_igm_instance_flexibility_policy_parent_tag]
28+
resource "google_compute_instance_template" "default" {
29+
name = "example-template"
30+
machine_type = "e2-medium"
31+
disk {
32+
source_image = "debian-cloud/debian-11"
33+
}
34+
network_interface {
35+
network = "default"
36+
}
37+
}
38+
39+
# [START compute_region_igm_instance_flexibility_policy]
40+
resource "google_compute_region_instance_group_manager" "default" {
41+
name = "flex-igm"
42+
base_instance_name = "tf-test-flex-igm"
43+
region = "us-central1"
44+
45+
target_size = 3
46+
distribution_policy_target_shape = "ANY_SINGLE_ZONE"
47+
48+
version {
49+
instance_template = google_compute_instance_template.default.id
50+
}
51+
52+
instance_flexibility_policy {
53+
instance_selections {
54+
name = "best-choice"
55+
rank = 1
56+
machine_types = [ "n1-standard-1", "n1-standard-2" ]
57+
}
58+
instance_selections {
59+
name = "still-ok"
60+
rank = 2
61+
machine_types = [ "n2-standard-1" ]
62+
}
63+
instance_selections {
64+
name = "if-nothing-else"
65+
rank = 3
66+
machine_types = [ "e2-standard-2" ]
67+
}
68+
}
69+
70+
update_policy {
71+
instance_redistribution_type = "NONE"
72+
type = "OPPORTUNISTIC"
73+
minimal_action = "REPLACE"
74+
max_surge_fixed = 0
75+
max_unavailable_fixed = 6
76+
}
77+
}
78+
# [END compute_region_igm_instance_flexibility_policy]
79+
# [END compute_region_igm_instance_flexibility_policy_parent_tag]

0 commit comments

Comments
 (0)