...

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

Documentation: github.com/GoogleCloudPlatform/k8s-config-connector/scripts/resource-autogen/generated/samples/Compute-ComputePerInstanceConfig-stateful_igm-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_instance_group_manager" "igm-no-tp" {
    45  description = "Terraform test instance group manager"
    46  name        = "my-igm"
    47
    48  version {
    49    name              = "prod"
    50    instance_template = google_compute_instance_template.igm-basic.self_link
    51  }
    52
    53  base_instance_name = "igm-no-tp"
    54  zone               = "us-central1-c"
    55  target_size        = 2
    56}
    57
    58resource "google_compute_disk" "default" {
    59  name  = "my-disk-name"
    60  type  = "pd-ssd"
    61  zone  = google_compute_instance_group_manager.igm.zone
    62  image = "debian-11-bullseye-v20220719"
    63  physical_block_size_bytes = 4096
    64}
    65
    66resource "google_compute_per_instance_config" "with_disk" {
    67  zone = google_compute_instance_group_manager.igm.zone
    68  instance_group_manager = google_compute_instance_group_manager.igm.name
    69  name = "instance-1"
    70  preserved_state {
    71    metadata = {
    72      foo = "bar"
    73      // Adding a reference to the instance template used causes the stateful instance to update
    74      // if the instance template changes. Otherwise there is no explicit dependency and template
    75      // changes may not occur on the stateful instance
    76      instance_template = google_compute_instance_template.igm-basic.self_link
    77    }
    78
    79    disk {
    80      device_name = "my-stateful-disk"
    81      source      = google_compute_disk.default.id
    82      mode        = "READ_ONLY"
    83    }
    84  }
    85}
    86```

View as plain text