-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
66 lines (55 loc) · 1.3 KB
/
main.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
60
61
62
63
64
65
66
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "3.53"
}
}
backend "remote" {
organization = "leonardo-scalabrini"
workspaces {
name = "cep-backend"
}
}
}
provider "google" {
credentials = var.cloud_credential
project = var.project_id
region = var.region
zone = var.zone
}
resource "google_project_service" "run_api" {
service = "run.googleapis.com"
}
resource "google_cloud_run_service" "cep-backend" {
name = "cep-backend"
location = var.region
template {
spec {
containers {
image = var.image
env {
name = "STRING_CONNECTION_DB"
}
}
}
}
autogenerate_revision_name = true
traffic {
percent = 100
latest_revision = true
}
depends_on = [google_project_service.run_api]
lifecycle {
ignore_changes = [template.0.spec.0.containers.0.image]
}
}
resource "google_cloud_run_service_iam_member" "run_all_users" {
service = google_cloud_run_service.cep-backend.name
location = google_cloud_run_service.cep-backend.location
role = "roles/run.invoker"
member = "allUsers"
}
output "service_url" {
value = google_cloud_run_service.cep-backend.status[0].url
}