...

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

Documentation: github.com/GoogleCloudPlatform/k8s-config-connector/scripts/resource-autogen/generated/samples/Compute-ComputeReservation-shared_reservation_basic

     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
    18resource "google_project" "owner_project" {
    19  project_id      = "tf-test%{random_suffix}"
    20  name            = "tf-test%{random_suffix}"
    21  org_id          = "123456789"
    22  billing_account = "000000-0000000-0000000-000000"
    23}
    24
    25
    26resource "google_project_service" "compute" {
    27  project = google_project.owner_project.project_id
    28  service = "compute.googleapis.com"
    29  disable_on_destroy = false
    30}
    31
    32resource "google_project" "guest_project" {
    33  project_id      = "tf-test-2%{random_suffix}"
    34  name            = "tf-test-2%{random_suffix}"
    35  org_id          = "123456789"
    36}
    37
    38resource "google_organization_policy" "shared_reservation_org_policy" {
    39  org_id     = "123456789"
    40  constraint = "constraints/compute.sharedReservationsOwnerProjects"
    41  list_policy {
    42    allow {
    43      values = ["projects/${google_project.owner_project.number}"]
    44    }
    45  }
    46}
    47
    48resource "google_compute_reservation" "gce_reservation" {
    49  project = google_project.owner_project.project_id
    50  name = "gce-shared-reservation"
    51  zone = "us-central1-a"
    52
    53  specific_reservation {
    54    count = 1
    55    instance_properties {
    56      min_cpu_platform = "Intel Cascade Lake"
    57      machine_type     = "n2-standard-2"
    58    }
    59  }
    60  share_settings {
    61    share_type = "SPECIFIC_PROJECTS"
    62    project_map {
    63      id = google_project.guest_project.project_id
    64      project_id = google_project.guest_project.project_id
    65    }
    66  }
    67  depends_on = [google_organization_policy.shared_reservation_org_policy,google_project_service.compute]
    68}
    69```

View as plain text