...

Text file src/github.com/GoogleCloudPlatform/k8s-config-connector/scripts/resource-autogen/generated/samples/CloudFunctions2-CloudFunctions2Function-cloudfunctions2_basic/main.tf

Documentation: github.com/GoogleCloudPlatform/k8s-config-connector/scripts/resource-autogen/generated/samples/CloudFunctions2-CloudFunctions2Function-cloudfunctions2_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
    18# [START functions_v2_basic]
    19locals {
    20  project = "my-project-name" # Google Cloud Platform Project ID
    21}
    22
    23resource "google_storage_bucket" "bucket" {
    24  name     = "${local.project}-gcf-source"  # Every bucket name must be globally unique
    25  location = "US"
    26  uniform_bucket_level_access = true
    27}
    28 
    29resource "google_storage_bucket_object" "object" {
    30  name   = "function-source.zip"
    31  bucket = google_storage_bucket.bucket.name
    32  source = "function-source.zip"  # Add path to the zipped function source code
    33}
    34 
    35resource "google_cloudfunctions2_function" "function" {
    36  name = "function-v2"
    37  location = "us-central1"
    38  description = "a new function"
    39 
    40  build_config {
    41    runtime = "nodejs16"
    42    entry_point = "helloHttp"  # Set the entry point 
    43    source {
    44      storage_source {
    45        bucket = google_storage_bucket.bucket.name
    46        object = google_storage_bucket_object.object.name
    47      }
    48    }
    49  }
    50 
    51  service_config {
    52    max_instance_count  = 1
    53    available_memory    = "256M"
    54    timeout_seconds     = 60
    55  }
    56}
    57
    58output "function_uri" { 
    59  value = google_cloudfunctions2_function.function.service_config[0].uri
    60}
    61# [END functions_v2_basic]
    62```

View as plain text