Skip to content

Commit 63a93ce

Browse files
feat(compute): add terraform sample for instanceflexibilitypolicy of rmig
1 parent 3346881 commit 63a93ce

File tree

1 file changed

+80
-0
lines changed
  • compute/rmig_instance_flexibility_policy

1 file changed

+80
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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+
provider = google-beta
42+
name = "flex-igm"
43+
base_instance_name = "tf-test-flex-igm"
44+
region = "us-central1"
45+
46+
target_size = 3
47+
distribution_policy_target_shape = "ANY_SINGLE_ZONE"
48+
49+
version {
50+
instance_template = google_compute_instance_template.default.id
51+
}
52+
53+
instance_flexibility_policy {
54+
instance_selections {
55+
name = "best-choice"
56+
rank = 1
57+
machine_types = [ "n1-standard-1", "n1-standard-2" ]
58+
}
59+
instance_selections {
60+
name = "still-ok"
61+
rank = 2
62+
machine_types = [ "n2-standard-1" ]
63+
}
64+
instance_selections {
65+
name = "if-nothing-else"
66+
rank = 3
67+
machine_types = [ "e2-standard-2" ]
68+
}
69+
}
70+
71+
update_policy {
72+
instance_redistribution_type = "NONE"
73+
type = "OPPORTUNISTIC"
74+
minimal_action = "REPLACE"
75+
max_surge_fixed = 0
76+
max_unavailable_fixed = 6
77+
}
78+
}
79+
# [END compute_region_igm_instance_flexibility_policy]
80+
# [END compute_region_igm_instance_flexibility_policy_parent_tag]

0 commit comments

Comments
 (0)