From ce62b276a840b56347bb4e119c3e8fda5ea31ec3 Mon Sep 17 00:00:00 2001 From: Yvonne Li Date: Mon, 24 Jul 2023 11:05:33 -0700 Subject: [PATCH] fix: Shorten storage bucket name (#43) Co-authored-by: Balaji Subramaniam --- README.md | 2 +- main.tf | 7 ++++--- metadata.yaml | 2 +- variables.tf | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6763996..fdcbd7f 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Deployment: 10 mins | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| bucket\_name | The name of the bucket to create | `string` | `"genai-doc-summary-webhook"` | no | +| bucket\_name | The name of the bucket to create | `string` | `"genai-webhook"` | no | | gcf\_timeout\_seconds | GCF execution timeout | `number` | `900` | no | | project\_id | The Google Cloud project ID to deploy to | `string` | n/a | yes | | region | Google Cloud region | `string` | `"us-central1"` | no | diff --git a/main.tf b/main.tf index 70b51d8..3694a81 100644 --- a/main.tf +++ b/main.tf @@ -74,7 +74,8 @@ resource "time_sleep" "wait_for_apis" { create_duration = var.time_to_enable_apis } -resource "random_uuid" "rand" { +resource "random_id" "rand" { + byte_length = 4 } data "archive_file" "webhook" { @@ -123,7 +124,7 @@ resource "google_cloudfunctions2_function" "webhook" { entry_point = "entrypoint" source { storage_source { - bucket = "${var.bucket_name}-${random_uuid.rand.id}" + bucket = "${var.bucket_name}-${random_id.rand.hex}" object = google_storage_bucket_object.webhook.name } } @@ -226,7 +227,7 @@ resource "google_storage_bucket" "output" { resource "google_storage_bucket" "main" { project = var.project_id - name = "${var.bucket_name}-${random_uuid.rand.id}" + name = "${var.bucket_name}-${random_id.rand.hex}" location = "US" uniform_bucket_level_access = true } diff --git a/metadata.yaml b/metadata.yaml index 95aba39..e356f44 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -83,7 +83,7 @@ spec: - name: bucket_name description: The name of the bucket to create varType: string - defaultValue: genai-doc-summary-webhook-1234 + defaultValue: genai-webhook - name: gcf_timeout_seconds description: GCF execution timeout varType: number diff --git a/variables.tf b/variables.tf index f288c6f..33040ff 100644 --- a/variables.tf +++ b/variables.tf @@ -26,7 +26,7 @@ variable "project_id" { variable "bucket_name" { description = "The name of the bucket to create" type = string - default = "genai-doc-summary-webhook" + default = "genai-webhook" } variable "region" {