Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ibhaskar2 authored Nov 28, 2023
2 parents 75d0b5b + 0c0833a commit 825c31f
Show file tree
Hide file tree
Showing 8 changed files with 303 additions and 11 deletions.
9 changes: 8 additions & 1 deletion compute/add_persistent_disk/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,16 @@ resource "google_compute_instance" "test_node" {
network_interface {
network = "default"
access_config {
// Ephemeral IP
# Ephemeral IP
}
}

# Ignore changes for persistant disk attachments
lifecycle {
ignore_changes = [attached_disk]
}


}
# [END compute_attach_persistent_disk]
# [END compute_add_persistent_disk_parent_tag]
55 changes: 55 additions & 0 deletions compute/mig_stateful_disk_basic/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Made to resemble:
* gcloud compute instance-groups managed create igm-stateful-disk-basic \
* --template example-tempalte \
* --size 1 \
* --stateful-disk device-name=bootdisk,auto-delete=NEVER
*/

# [START compute_zonal_mig_stateful_disk_basic_parent_tag]
resource "google_compute_instance_template" "default" {
name = "example-template"
machine_type = "e2-medium"
disk {
device_name = "bootdisk"
source_image = "debian-cloud/debian-11"
}
network_interface {
network = "default"
}
}

# [START compute_zonal_mig_stateful_disk_basic]
resource "google_compute_instance_group_manager" "default" {
name = "igm-stateful-disk-basic"
zone = "us-central1-f"
base_instance_name = "instance"
target_size = 1

version {
instance_template = google_compute_instance_template.default.id
}

stateful_disk {
device_name = "bootdisk"
delete_rule = "NEVER"
}

}
# [END compute_zonal_mig_stateful_disk_basic]
# [END compute_zonal_mig_stateful_disk_basic_parent_tag]
55 changes: 55 additions & 0 deletions compute/rmig_redistribution/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Made to resemble:
* gcloud compute instance-groups managed create example-rmig \
* --template example-template \
* --size 30 \
* --zones us-east1-b,us-east1-c \
* --instance-redistribution-type NONE
*/

# [START compute_region_igm_redistribution_parent_tag]
resource "google_compute_instance_template" "default" {
name = "example-template"
machine_type = "e2-medium"
disk {
source_image = "debian-cloud/debian-11"
}
network_interface {
network = "default"
}
}

# [START compute_region_igm_redistribution]
resource "google_compute_region_instance_group_manager" "default" {
name = "example-rmig"
region = "us-east1"
distribution_policy_zones = ["us-east1-b", "us-east1-c"]
update_policy {
type = "PROACTIVE"
minimal_action = "REFRESH"
instance_redistribution_type = "NONE"
max_unavailable_fixed = 3
}
target_size = 30
base_instance_name = "instance"
version {
instance_template = google_compute_instance_template.default.id
}
}
# [END compute_region_igm_redistribution]
# [END compute_region_igm_redistribution_parent_tag]
57 changes: 57 additions & 0 deletions compute/rmig_shape/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Made to resemble:
* gcloud compute instance-groups managed create example-rmig \
* --template example-template \
* --size 30 \
* --zones us-east1-b,us-east1-c \
* --target-distribution-shape balanced \
* --instance-redistribution-type NONE
*/

# [START compute_region_igm_shape_parent_tag]
resource "google_compute_instance_template" "default" {
name = "example-template"
machine_type = "e2-medium"
disk {
source_image = "debian-cloud/debian-11"
}
network_interface {
network = "default"
}
}

# [START compute_region_igm_shape]
resource "google_compute_region_instance_group_manager" "default" {
name = "example-rmig"
region = "us-east1"
distribution_policy_zones = ["us-east1-b", "us-east1-c"]
distribution_policy_target_shape = "BALANCED"
update_policy {
type = "PROACTIVE"
minimal_action = "REFRESH"
instance_redistribution_type = "NONE"
max_unavailable_fixed = 3
}
target_size = 30
base_instance_name = "instance"
version {
instance_template = google_compute_instance_template.default.id
}
}
# [END compute_region_igm_shape]
# [END compute_region_igm_shape_parent_tag]
48 changes: 48 additions & 0 deletions compute/rmig_zones_spreading/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Made to resemble:
* gcloud compute instance-groups managed create example-rmig \
* --template example-template \
* --size 30 \
* --zones us-east1-b,us-east1-c
*/

# [START compute_region_igm_spreading_parent_tag]
resource "google_compute_instance_template" "default" {
name = "example-template"
machine_type = "e2-medium"
disk {
source_image = "debian-cloud/debian-11"
}
network_interface {
network = "default"
}
}

# [START compute_region_igm_spreading]
resource "google_compute_region_instance_group_manager" "default" {
name = "example-rmig"
region = "us-east1"
distribution_policy_zones = ["us-east1-b", "us-east1-c"]
target_size = 30
base_instance_name = "instance"
version {
instance_template = google_compute_instance_template.default.id
}
}
# [END compute_region_igm_spreading_parent_tag]
# [END compute_region_igm_spreading]
61 changes: 61 additions & 0 deletions compute/stateful_instance_group_manager/metadata/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Made to resemble:
* gcloud compute instance-groups managed [create-instance|instance-configs update] example-cluster \
* --instance node-12 \
* --stateful-metadata mode=active,logging=elaborate
*/

# [START compute_stateful_instance_group_manager_metadata_parent_tag]
resource "google_compute_instance_template" "default" {
machine_type = "e2-medium"

disk {
source_image = "debian-cloud/debian-11"
}

network_interface {
network = "default"
}
}

resource "google_compute_instance_group_manager" "default" {
name = "example-cluster"
base_instance_name = "test"
target_size = 1
zone = "europe-west4-a"

version {
instance_template = google_compute_instance_template.default.id
name = "primary"
}
}
# [START compute_stateful_instance_group_manager_metadata_pic]
resource "google_compute_per_instance_config" "default" {
instance_group_manager = google_compute_instance_group_manager.default.name
zone = google_compute_instance_group_manager.default.zone
name = "node-12"
preserved_state {
metadata = {
mode = "active"
logging = "elaborate"
}
}
}
# [END compute_stateful_instance_group_manager_metadata_pic]
# [END compute_stateful_instance_group_manager_metadata_parent_tag]
9 changes: 5 additions & 4 deletions test/integration/go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module github.com/terraform-google-modules/terraform-docs-samples/test/integration

go 1.19
go 1.21


require (
github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test v0.9.2
github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test v0.10.1
github.com/stretchr/testify v1.8.4
)

Expand Down Expand Up @@ -31,7 +32,7 @@ require (
github.com/google/uuid v1.3.1 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
github.com/gruntwork-io/terratest v0.43.13 // indirect
github.com/gruntwork-io/terratest v0.46.6 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-getter v1.7.2 // indirect
Expand Down Expand Up @@ -59,7 +60,7 @@ require (
github.com/zclconf/go-cty v1.14.0 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.12.0 // indirect
golang.org/x/sync v0.3.0 // indirect
Expand Down
Loading

0 comments on commit 825c31f

Please sign in to comment.