Skip to content

Commit 0b965f4

Browse files
feat: Add example with stateful disks in stateful policy (terraform-google-modules#578)
* Added example for Zonal MIGs * Update compute/zonal_instance_group_manager/main.tf Co-authored-by: Sampath Kumar <[email protected]> * Update compute/zonal_instance_group_manager/main.tf Co-authored-by: Sampath Kumar <[email protected]> * Update compute/zonal_instance_group_manager/main.tf Co-authored-by: Sampath Kumar <[email protected]> * changed base instance name for instances in the mig * add example with stateful disks in stateful policy --------- Co-authored-by: Sampath Kumar <[email protected]>
1 parent 644581f commit 0b965f4

File tree

1 file changed

+55
-0
lines changed
  • compute/zonal_mig_stateful_policy_disk

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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 compute instance-groups managed create example-database-group \
20+
* --template example-database-template-v01 \
21+
* --base-instance-name shard \
22+
* --size 12 \
23+
* --stateful-disk device-name=data-disk,auto-delete=on-permanent-instance-deletion
24+
*/
25+
26+
# [START compute_stateful_instance_group_manager_disk_policy_parent_tag]
27+
resource "google_compute_instance_template" "default" {
28+
name = "example-database-template-v01"
29+
machine_type = "e2-medium"
30+
disk {
31+
device_name = "data-disk"
32+
source_image = "debian-cloud/debian-11"
33+
}
34+
network_interface {
35+
network = "default"
36+
}
37+
}
38+
39+
# [START compute_stateful_instance_group_manager_disk_policy]
40+
resource "google_compute_instance_group_manager" "default" {
41+
name = "example-database-group"
42+
base_instance_name = "shard"
43+
target_size = 12
44+
zone = "us-central1-f"
45+
version {
46+
instance_template = google_compute_instance_template.default.id
47+
name = "primary"
48+
}
49+
stateful_disk {
50+
device_name = "data-disk"
51+
delete_rule = "ON_PERMANENT_INSTANCE_DELETION"
52+
}
53+
}
54+
# [END compute_stateful_instance_group_manager_disk_policy]
55+
# [END compute_stateful_instance_group_manager_disk_policy_parent_tag]

0 commit comments

Comments
 (0)