...

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

Documentation: github.com/GoogleCloudPlatform/k8s-config-connector/scripts/resource-autogen/generated/samples/Compute-ComputeServiceAttachment-service_attachment_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_compute_service_attachment" "psc_ilb_service_attachment" {
    19  name        = "my-psc-ilb"
    20  region      = "us-west2"
    21  description = "A service attachment configured with Terraform"
    22
    23  domain_names             = ["gcp.tfacc.hashicorptest.com."]
    24  enable_proxy_protocol    = true
    25  connection_preference    = "ACCEPT_AUTOMATIC"
    26  nat_subnets              = [google_compute_subnetwork.psc_ilb_nat.id]
    27  target_service           = google_compute_forwarding_rule.psc_ilb_target_service.id
    28}
    29
    30resource "google_compute_address" "psc_ilb_consumer_address" {
    31  name   = "psc-ilb-consumer-address"
    32  region = "us-west2"
    33
    34  subnetwork   = "default"
    35  address_type = "INTERNAL"
    36}
    37
    38resource "google_compute_forwarding_rule" "psc_ilb_consumer" {
    39  name   = "psc-ilb-consumer-forwarding-rule"
    40  region = "us-west2"
    41
    42  target                = google_compute_service_attachment.psc_ilb_service_attachment.id
    43  load_balancing_scheme = "" # need to override EXTERNAL default when target is a service attachment
    44  network               = "default"
    45  ip_address            = google_compute_address.psc_ilb_consumer_address.id
    46}
    47
    48resource "google_compute_forwarding_rule" "psc_ilb_target_service" {
    49  name   = "producer-forwarding-rule"
    50  region = "us-west2"
    51
    52  load_balancing_scheme = "INTERNAL"
    53  backend_service       = google_compute_region_backend_service.producer_service_backend.id
    54  all_ports             = true
    55  network               = google_compute_network.psc_ilb_network.name
    56  subnetwork            = google_compute_subnetwork.psc_ilb_producer_subnetwork.name
    57}
    58
    59resource "google_compute_region_backend_service" "producer_service_backend" {
    60  name   = "producer-service"
    61  region = "us-west2"
    62
    63  health_checks = [google_compute_health_check.producer_service_health_check.id]
    64}
    65
    66resource "google_compute_health_check" "producer_service_health_check" {
    67  name = "producer-service-health-check"
    68
    69  check_interval_sec = 1
    70  timeout_sec        = 1
    71  tcp_health_check {
    72    port = "80"
    73  }
    74}
    75
    76resource "google_compute_network" "psc_ilb_network" {
    77  name = "psc-ilb-network"
    78  auto_create_subnetworks = false
    79}
    80
    81resource "google_compute_subnetwork" "psc_ilb_producer_subnetwork" {
    82  name   = "psc-ilb-producer-subnetwork"
    83  region = "us-west2"
    84
    85  network       = google_compute_network.psc_ilb_network.id
    86  ip_cidr_range = "10.0.0.0/16"
    87}
    88
    89resource "google_compute_subnetwork" "psc_ilb_nat" {
    90  name   = "psc-ilb-nat"
    91  region = "us-west2"
    92
    93  network       = google_compute_network.psc_ilb_network.id
    94  purpose       =  "PRIVATE_SERVICE_CONNECT"
    95  ip_cidr_range = "10.1.0.0/16"
    96}
    97```

View as plain text