-
Notifications
You must be signed in to change notification settings - Fork 1
/
storage.tf
59 lines (54 loc) · 2.42 KB
/
storage.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#Create a GCS bucket to store the image analysisremote function source code
## Use a random string for the bucket name to avoid conflicts
resource "google_storage_bucket" "function_source" {
name = "gemini-bq-demo-${random_id.id.hex}"
project = module.project-services.project_id
location = var.region
uniform_bucket_level_access = true
force_destroy = var.force_destroy
depends_on = [time_sleep.wait_after_apis]
}
##Upload the image analysis function source code to the bucket
resource "google_storage_bucket_object" "image_source_upload" {
name = "image_function_source.zip"
bucket = google_storage_bucket.function_source.name
source = data.archive_file.create_image_function_zip.output_path
}
##Upload the text analysis function source code to the bucket
resource "google_storage_bucket_object" "text_source_upload" {
name = "text_function_source.zip"
bucket = google_storage_bucket.function_source.name
source = data.archive_file.create_text_function_zip.output_path
}
# Create a GCS bucket to upload demo images
## Use a random string for the bucket name to avoid conflicts
resource "google_storage_bucket" "demo_images" {
name = "gemini-bq-demo-images${random_id.id.hex}"
project = module.project-services.project_id
location = var.region
uniform_bucket_level_access = true
force_destroy = var.force_destroy
depends_on = [time_sleep.wait_after_apis]
}
## Upload the sample images to the bucket
resource "google_storage_bucket_object" "image_upload" {
for_each = fileset("${path.module}/src/images", "*.jpg")
name = each.value
bucket = google_storage_bucket.demo_images.name
source = "${path.module}/src/images/${each.value}"
}