-
Notifications
You must be signed in to change notification settings - Fork 1
/
thumbnail.tf
77 lines (61 loc) · 1.72 KB
/
thumbnail.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
67
68
69
70
71
72
73
74
75
76
77
resource "google_storage_notification" "notification" {
bucket = google_storage_bucket.bucket.name
payload_format = "JSON_API_V1"
topic = google_pubsub_topic.topic.id
event_types = ["OBJECT_FINALIZE"]
object_name_prefix = "images/"
custom_attributes = {
width = "800"
}
depends_on = [google_pubsub_topic_iam_binding.binding]
}
data "google_storage_project_service_account" "gcs_account" {
}
resource "google_pubsub_topic_iam_binding" "binding" {
topic = google_pubsub_topic.topic.id
role = "roles/pubsub.publisher"
members = ["serviceAccount:${data.google_storage_project_service_account.gcs_account.email_address}"]
}
resource "google_pubsub_topic" "topic" {
name = "default_topic"
}
resource "google_pubsub_subscription" "subscription" {
name = "subscription"
topic = google_pubsub_topic.topic.name
ack_deadline_seconds = 20
push_config {
push_endpoint = google_cloud_run_service.resize.status.0.url
attributes = {
x-goog-version = "v1"
}
}
}
resource "google_cloud_run_service" "resize" {
name = "resize"
location = "us-central1"
template {
spec {
containers {
image = "gcr.io/terraforming-with-freeman/resize:v0.0.2"
}
}
}
traffic {
percent = 100
latest_revision = true
}
}
data "google_iam_policy" "noauth" {
binding {
role = "roles/run.invoker"
members = [
"allUsers",
]
}
}
resource "google_cloud_run_service_iam_policy" "noauth-resize" {
location = google_cloud_run_service.resize.location
project = google_cloud_run_service.resize.project
service = google_cloud_run_service.resize.name
policy_data = data.google_iam_policy.noauth.policy_data
}