...

Text file src/github.com/GoogleCloudPlatform/k8s-config-connector/scripts/resource-autogen/generated/samples/AlloyDB-AlloyDBInstance-alloydb_instance_basic/main.tf

Documentation: github.com/GoogleCloudPlatform/k8s-config-connector/scripts/resource-autogen/generated/samples/AlloyDB-AlloyDBInstance-alloydb_instance_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_alloydb_instance" "default" {
    19  cluster       = google_alloydb_cluster.default.name
    20  instance_id   = "alloydb-instance"
    21  instance_type = "PRIMARY"
    22
    23  machine_config {
    24    cpu_count = 2
    25  }
    26
    27  depends_on = [google_service_networking_connection.vpc_connection]
    28}
    29
    30resource "google_alloydb_cluster" "default" {
    31  cluster_id = "alloydb-cluster"
    32  location   = "us-central1"
    33  network    = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}"
    34
    35  initial_user {
    36    password = "alloydb-cluster"
    37  }
    38}
    39
    40data "google_project" "project" {}
    41
    42resource "google_compute_network" "default" {
    43  name = "alloydb-cluster"
    44}
    45
    46resource "google_compute_global_address" "private_ip_alloc" {
    47  name          =  "alloydb-cluster"
    48  address_type  = "INTERNAL"
    49  purpose       = "VPC_PEERING"
    50  prefix_length = 16
    51  network       = google_compute_network.default.id
    52}
    53
    54resource "google_service_networking_connection" "vpc_connection" {
    55  network                 = google_compute_network.default.id
    56  service                 = "servicenetworking.googleapis.com"
    57  reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name]
    58}
    59```

View as plain text