...

Text file src/github.com/GoogleCloudPlatform/k8s-config-connector/scripts/resource-autogen/generated/samples/Compute-ComputeRegionPerInstanceConfig-stateful_rigm-skipped/main.tf

Documentation: github.com/GoogleCloudPlatform/k8s-config-connector/scripts/resource-autogen/generated/samples/Compute-ComputeRegionPerInstanceConfig-stateful_rigm-skipped

     1/**
     2 * Copyright 2022 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```hcl
    18data "google_compute_image" "my_image" {
    19  family  = "debian-11"
    20  project = "debian-cloud"
    21}
    22
    23resource "google_compute_instance_template" "igm-basic" {
    24  name           = "my-template"
    25  machine_type   = "e2-medium"
    26  can_ip_forward = false
    27  tags           = ["foo", "bar"]
    28
    29  disk {
    30    source_image = data.google_compute_image.my_image.self_link
    31    auto_delete  = true
    32    boot         = true
    33  }
    34
    35  network_interface {
    36    network = "default"
    37  }
    38
    39  service_account {
    40    scopes = ["userinfo-email", "compute-ro", "storage-ro"]
    41  }
    42}
    43
    44resource "google_compute_region_instance_group_manager" "rigm" {
    45  description = "Terraform test instance group manager"
    46  name        = "my-rigm"
    47
    48  version {
    49    name              = "prod"
    50    instance_template = google_compute_instance_template.igm-basic.self_link
    51  }
    52
    53  update_policy {
    54    type                         = "OPPORTUNISTIC"
    55    instance_redistribution_type = "NONE"
    56    minimal_action               = "RESTART"
    57  }
    58
    59  base_instance_name = "rigm"
    60  region             = "us-central1"
    61  target_size        = 2
    62}
    63
    64resource "google_compute_disk" "default" {
    65  name  = "my-disk-name"
    66  type  = "pd-ssd"
    67  zone  = "us-central1-a"
    68  image = "debian-11-bullseye-v20220719"
    69  physical_block_size_bytes = 4096
    70}
    71
    72resource "google_compute_region_per_instance_config" "with_disk" {
    73  region = google_compute_region_instance_group_manager.igm.region
    74  region_instance_group_manager = google_compute_region_instance_group_manager.rigm.name
    75  name = "instance-1"
    76  preserved_state {
    77    metadata = {
    78      foo = "bar"
    79      // Adding a reference to the instance template used causes the stateful instance to update
    80      // if the instance template changes. Otherwise there is no explicit dependency and template
    81      // changes may not occur on the stateful instance
    82      instance_template = google_compute_instance_template.igm-basic.self_link
    83    }
    84
    85    disk {
    86      device_name = "my-stateful-disk"
    87      source      = google_compute_disk.default.id
    88      mode        = "READ_ONLY"
    89    }
    90  }
    91}
    92```

View as plain text