Skip to content

Commit 89b7be8

Browse files
committed
fix: deployment
1 parent c4aca71 commit 89b7be8

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

infra/functions-python/main.tf

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,24 @@ resource "google_cloudfunctions2_function_iam_member" "reverse_geolocation_proce
10771077
member = "serviceAccount:${local.batchfunctions_sa_email}"
10781078
}
10791079

1080+
# Grant execution permission to bathcfunctions service account to the pmtiles_builder function
1081+
resource "google_cloudfunctions2_function_iam_member" "pmtiles_builder_invoker_batch_sa" {
1082+
project = var.project_id
1083+
location = var.gcp_region
1084+
cloud_function = google_cloudfunctions2_function.pmtiles_builder.name
1085+
role = "roles/cloudfunctions.invoker"
1086+
member = "serviceAccount:${local.batchfunctions_sa_email}"
1087+
}
1088+
1089+
# Grant execution permission to the service account to the pmtiles_builder function
1090+
resource "google_cloudfunctions2_function_iam_member" "pmtiles_builder_invoker" {
1091+
project = var.project_id
1092+
location = var.gcp_region
1093+
cloud_function = google_cloudfunctions2_function.pmtiles_builder.name
1094+
role = "roles/cloudfunctions.invoker"
1095+
member = "serviceAccount:${google_service_account.functions_service_account.email}"
1096+
}
1097+
10801098
# 13.3 functions/reverse_geolocation - batch cloud function
10811099
resource "google_cloudfunctions2_function" "reverse_geolocation_batch" {
10821100
name = "${local.function_reverse_geolocation_config.name}-batch"
@@ -1128,6 +1146,27 @@ resource "google_cloudfunctions2_function" "reverse_geolocation_batch" {
11281146
}
11291147
}
11301148

1149+
# Task queue to invoke pmtiles_builder function
1150+
resource "google_cloud_tasks_queue" "pmtiles_builder_task_queue" {
1151+
project = var.project_id
1152+
location = var.gcp_region
1153+
name = "pmtiles-builder-queue-${var.environment}-${local.deployment_timestamp}"
1154+
1155+
rate_limits {
1156+
max_concurrent_dispatches = 1
1157+
max_dispatches_per_second = 1
1158+
}
1159+
1160+
retry_config {
1161+
# This will make the cloud task retry for ~1 hour
1162+
max_attempts = 31
1163+
min_backoff = "120s"
1164+
max_backoff = "120s"
1165+
max_doublings = 2
1166+
}
1167+
}
1168+
1169+
11311170
# 14. functions/tasks_executor cloud function
11321171
resource "google_cloudfunctions2_function" "tasks_executor" {
11331172
name = "${local.function_tasks_executor_config.name}-${var.environment}"
@@ -1154,6 +1193,9 @@ resource "google_cloudfunctions2_function" "tasks_executor" {
11541193
DATASET_PROCESSING_TOPIC_NAME = "datasets-batch-topic-${var.environment}"
11551194
MATERIALIZED_VIEW_QUEUE = google_cloud_tasks_queue.refresh_materialized_view_task_queue.name
11561195
DATASETS_BUCKET_NAME = "${var.datasets_bucket_name}-${var.environment}"
1196+
PMTILES_BUILDER_QUEUE = google_cloud_tasks_queue.pmtiles_builder_task_queue.name
1197+
SERVICE_ACCOUNT_EMAIL = google_service_account.functions_service_account.email
1198+
GCP_REGION = var.gcp_region
11571199
}
11581200
available_memory = local.function_tasks_executor_config.memory
11591201
timeout_seconds = local.function_tasks_executor_config.timeout

0 commit comments

Comments
 (0)