-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
48 lines (40 loc) · 1.37 KB
/
main.tf
File metadata and controls
48 lines (40 loc) · 1.37 KB
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
# Proveedor
provider "google" {
version = "3.5.0"
# Archivo JSON descargado desde la consola
credentials = file("<NAME>.json") // highlight-line
# ID del proyecto en GCP
project = "<PROJECT_ID>" // highlight-line
region = "us-central1"
zone = "us-central1-c"
}
# Bucket para almacenar el código fuente
resource "google_storage_bucket" "source_bucket" {
name = "hello-world-source"
location = "us-central1"
}
# Almacenar source.zip al bucket
resource "google_storage_bucket_object" "archive" {
name = "source.zip"
bucket = google_storage_bucket.source_bucket.name
source = "./source.zip"
}
# Cloud Function
resource "google_cloudfunctions_function" "function" {
name = "function-test"
description = "Hola Mundo"
runtime = "python37"
available_memory_mb = 128
source_archive_bucket = google_storage_bucket.source_bucket.name
source_archive_object = google_storage_bucket_object.archive.name
trigger_http = true
entry_point = "handler"
}
# Permiso para invocar la función
resource "google_cloudfunctions_function_iam_member" "invoker" {
project = google_cloudfunctions_function.function.project
region = google_cloudfunctions_function.function.region
cloud_function = google_cloudfunctions_function.function.name
role = "roles/cloudfunctions.invoker"
member = "allUsers"
}