-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjob_bootstrap.tf
125 lines (106 loc) · 2.85 KB
/
job_bootstrap.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
resource "google_service_account" "bootstrap" {
project = var.project_id
account_id = "gateway-${var.instance_name}-bootstrap"
display_name = "Awala Internet Gateway (Bootstrap, ${var.instance_name})"
}
resource "google_cloud_run_v2_job" "bootstrap" {
name = "gateway-${var.instance_name}-bootstrap"
location = var.region
template {
task_count = 1
template {
timeout = "300s"
service_account = google_service_account.bootstrap.email
execution_environment = "EXECUTION_ENVIRONMENT_GEN2"
max_retries = 1
containers {
name = "bootstrap"
image = "${var.docker_image_name}:${var.docker_image_tag}"
args = ["build/main/bin/generate-keypairs.js"]
env {
name = "INTERNET_ADDRESS"
value = local.sanitised_internet_address
}
env {
name = "GATEWAY_VERSION"
value = var.docker_image_tag
}
env {
name = "MONGODB_URI"
value = var.mongodb_uri
}
env {
name = "MONGODB_DB"
value = var.mongodb_db
}
env {
name = "MONGODB_USER"
value = var.mongodb_user
}
env {
name = "MONGODB_PASSWORD"
value_source {
secret_key_ref {
secret = google_secret_manager_secret.mongodb_password.id
version = "latest"
}
}
}
env {
name = "PRIVATE_KEY_STORE_ADAPTER"
value = "0"
}
// @relaycorp/awala-keystore-cloud options
env {
name = "KEYSTORE_ADAPTER"
value = "gcp"
}
env {
name = "KS_GCP_LOCATION"
value = var.region
}
env {
name = "KS_KMS_KEYRING"
value = google_kms_key_ring.keystores.name
}
env {
name = "KS_KMS_ID_KEY"
value = google_kms_crypto_key.identity_key.name
}
env {
name = "KS_KMS_SESSION_ENC_KEY"
value = google_kms_crypto_key.session_keys.name
}
env {
name = "LOG_LEVEL"
value = var.log_level
}
env {
name = "LOG_TARGET"
value = "gcp"
}
resources {
limits = {
cpu = 1
memory = "512Mi"
}
}
}
}
}
depends_on = [
time_sleep.wait_for_id_key_creation,
google_secret_manager_secret_iam_binding.mongodb_password_reader,
google_project_iam_binding.keystore_kms_user,
]
lifecycle {
ignore_changes = [launch_stage]
}
}
resource "google_cloud_run_v2_job_iam_binding" "endpoint_bootstrap_invoker" {
project = var.project_id
location = var.region
name = google_cloud_run_v2_job.bootstrap.name
role = "roles/run.invoker"
members = [var.sre_iam_uri]
}