-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.tf
75 lines (66 loc) · 2.7 KB
/
functions.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
locals {
artifact_registry_repository_name = "octue-twined-services"
}
resource "google_cloudfunctions2_function" "event_handler" {
name = "${var.environment}-octue-twined-service-event-handler"
description = "A function for handling events from Octue Twined services."
location = var.google_cloud_region
build_config {
runtime = "python312"
entry_point = "handle_event"
source {
storage_source {
bucket = "twined-gcp"
object = "event_handler/0.7.2.zip"
}
}
}
service_config {
max_instance_count = var.maximum_event_handler_instances
available_memory = "256M"
timeout_seconds = 60
ingress_settings = "ALLOW_INTERNAL_ONLY"
environment_variables = {
ARTIFACT_REGISTRY_REPOSITORY_URL = "${var.google_cloud_region}-docker.pkg.dev/${var.google_cloud_project_id}/${local.artifact_registry_repository_name}"
BIGQUERY_EVENTS_TABLE = "octue_twined.service-events"
KUBERNETES_CLUSTER_ID = google_container_cluster.primary.id
KUBERNETES_SERVICE_ACCOUNT_NAME = kubernetes_service_account.default.metadata[0].name
KUEUE_LOCAL_QUEUE = var.local_queue.name
OCTUE_SERVICES_TOPIC_NAME = google_pubsub_topic.services_topic.name
QUESTION_DEFAULT_CPUS = var.question_default_resources.cpus
QUESTION_DEFAULT_MEMORY = var.question_default_resources.memory
QUESTION_DEFAULT_EPHEMERAL_STORAGE = var.question_default_resources.ephemeral_storage
}
}
event_trigger {
event_type = "google.cloud.pubsub.topic.v1.messagePublished"
pubsub_topic = google_pubsub_topic.services_topic.id
trigger_region = var.google_cloud_region
retry_policy = "RETRY_POLICY_RETRY"
}
depends_on = [time_sleep.wait_for_google_apis_to_enable]
}
resource "google_cloudfunctions2_function" "service_registry" {
name = "${var.environment}-octue-twined-service-registry"
description = "A lightweight service registry for Octue Twined services running on Kueue."
location = var.google_cloud_region
build_config {
runtime = "python312"
entry_point = "handle_request"
source {
storage_source {
bucket = "twined-gcp"
object = "service_registry/0.7.0.zip"
}
}
}
service_config {
max_instance_count = var.maximum_service_registry_instances
available_memory = "256M"
timeout_seconds = 60
environment_variables = {
ARTIFACT_REGISTRY_REPOSITORY_ID = "projects/${var.google_cloud_project_id}/locations/${var.google_cloud_region}/repositories/${local.artifact_registry_repository_name}"
}
}
depends_on = [time_sleep.wait_for_google_apis_to_enable]
}