...

Text file src/github.com/GoogleCloudPlatform/k8s-config-connector/scripts/resource-autogen/generated/samples/CloudRunV2-CloudRunV2Job-cloudrunv2_job_sql/main.tf

Documentation: github.com/GoogleCloudPlatform/k8s-config-connector/scripts/resource-autogen/generated/samples/CloudRunV2-CloudRunV2Job-cloudrunv2_job_sql

     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_cloud_run_v2_job" "default" {
    19  name     = "cloudrun-job"
    20  location = "us-central1"
    21  launch_stage = "BETA"
    22  
    23  template {
    24    template{
    25      volumes {
    26        name = "cloudsql"
    27        cloud_sql_instance {
    28          instances = [google_sql_database_instance.instance.connection_name]
    29        }
    30      }
    31
    32      containers {
    33        image = "us-docker.pkg.dev/cloudrun/container/hello"
    34
    35        env {
    36          name = "FOO"
    37          value = "bar"
    38        }
    39        env {
    40          name = "latestdclsecret"
    41          value_source {
    42            secret_key_ref {
    43              secret = google_secret_manager_secret.secret.secret_id
    44              version = "1"
    45            }
    46          }
    47        }
    48        volume_mounts {
    49          name = "cloudsql"
    50          mount_path = "/cloudsql"
    51        }
    52      }
    53    }
    54  }
    55
    56  lifecycle {
    57    ignore_changes = [
    58      launch_stage,
    59    ]
    60  }
    61}
    62
    63data "google_project" "project" {
    64}
    65
    66resource "google_secret_manager_secret" "secret" {
    67  secret_id = "secret"
    68  replication {
    69    automatic = true
    70  }
    71}
    72
    73resource "google_secret_manager_secret_version" "secret-version-data" {
    74  secret = google_secret_manager_secret.secret.name
    75  secret_data = "secret-data"
    76}
    77
    78resource "google_secret_manager_secret_iam_member" "secret-access" {
    79  secret_id = google_secret_manager_secret.secret.id
    80  role      = "roles/secretmanager.secretAccessor"
    81  member    = "serviceAccount:${data.google_project.project.number}-compute@developer.gserviceaccount.com"
    82  depends_on = [google_secret_manager_secret.secret]
    83}
    84
    85resource "google_sql_database_instance" "instance" {
    86  name             = "cloudrun-sql"
    87  region           = "us-central1"
    88  database_version = "MYSQL_5_7"
    89  settings {
    90    tier = "db-f1-micro"
    91  }
    92
    93  deletion_protection  = "true"
    94}
    95```

View as plain text