-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.tf
83 lines (74 loc) · 2.01 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
provider "google" {
project = var.project_id
region = var.region
}
data "google_compute_default_service_account" "default" {
}
locals {
config_json = jsondecode(file("${path.module}/config.json"))
}
resource "google_cloud_run_v2_job" "default" {
name = var.cloud_run_name
location = var.region
template {
template {
containers {
image = var.image_url
resources {
limits = {
memory = "4Gi"
cpu = 2
}
}
env {
name = "SYNAPSE_AUTH_TOKEN"
value_source {
secret_key_ref {
secret = var.secret_id
version = "latest"
}
}
}
env {
name = "HTAN_CENTERS_MAP"
value = jsonencode(local.config_json.centers)
}
env {
name = "ATTRIBUTE_DESCRIPTIONS"
value = jsonencode(local.config_json.descriptions)
}
env {
name = "ASSAYS"
value = jsonencode(local.config_json.assays)
}
}
timeout = "2700s"
service_account = "${google_service_account.sa.email}"
}
}
lifecycle {
ignore_changes = [
launch_stage,
]
}
depends_on = [resource.google_service_account.sa]
}
resource "google_cloud_scheduler_job" "job" {
name = var.job_name
description = var.job_description
schedule = var.job_schedule
time_zone = var.time_zone
attempt_deadline = "320s"
region = var.region
retry_config {
retry_count = 3
}
http_target {
http_method = "POST"
uri = "https://${var.region}-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/${var.project_id}/jobs/${google_cloud_run_v2_job.default.name}:run"
oauth_token {
service_account_email = data.google_compute_default_service_account.default.email
}
}
depends_on = [resource.google_cloud_run_v2_job.default]
}