Skip to content

Commit 4698115

Browse files
committed
set cloud name dynamic
1 parent 5093612 commit 4698115

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

infra/functions-python/main.tf

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,12 @@ resource "google_cloud_tasks_queue" "cloud_tasks_dead_letter_queue" {
370370

371371
# Create a queue for the cloud tasks
372372
# The 2X rate is defined as 4*2 concurrent dispatches and 1 dispatch per second
373+
# The name of the queue need to be dynamic due to GCP limitations
374+
# references:
375+
# - https://cloud.google.com/tasks/docs/deleting-appengine-queues-and-tasks#deleting_queues
376+
# - https://issuetracker.google.com/issues/263947953
373377
resource "google_cloud_tasks_queue" "cloud_tasks_2x_rate_queue" {
374-
name = "cloud-tasks-2x-rate-queue-${var.environment}"
378+
name = "cloud-tasks-2x-rate-queue-${var.environment}-${formatdate("YYYYMMDDhhmmss", timestamp())}"
375379
location = var.gcp_region
376380

377381
rate_limits {
@@ -388,6 +392,10 @@ resource "google_cloud_tasks_queue" "cloud_tasks_2x_rate_queue" {
388392
}
389393
}
390394

395+
output "processing_report_cloud_task_name" {
396+
value = google_cloud_tasks_queue.cloud_tasks_2x_rate_queue.name
397+
}
398+
391399
resource "google_cloudfunctions2_function" "process_validation_report" {
392400
name = local.function_process_validation_report_config.name
393401
description = local.function_process_validation_report_config.description

infra/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ module "workflows" {
116116
gcp_region = var.gcp_region
117117
environment = var.environment
118118
validator_endpoint = var.validator_endpoint
119+
processing_report_cloud_task_name = module.functions-python.processing_report_cloud_task_name
119120
}
120121

121122
module "feed-api-load-balancer" {

infra/workflows/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ resource "google_workflows_workflow" "gtfs_validator_execution" {
9090
reports_bucket_name = lower(var.environment) == "prod" ? var.reports_bucket_name : "stg-${var.reports_bucket_name}"
9191
validator_endpoint = var.validator_endpoint
9292
environment = lower(var.environment)
93+
processing_report_cloud_task_name = var.processing_report_cloud_task_name
9394
}
9495
source_contents = file("${path.module}../../../workflows/gtfs_validator_execution.yml")
9596
}

infra/workflows/vars.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,8 @@ variable "validator_endpoint" {
5151
type = string
5252
description = "URL of the validator endpoint"
5353
}
54+
55+
variable "processing_report_cloud_task_name" {
56+
type = string
57+
description = "The cloud task name to call the process report task"
58+
}

workflows/gtfs_validator_execution.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ main:
1919
- datasetID: ${text.split(data.resourceName, "/")[6]}
2020
- region: ${resource.labels.location}
2121
- projectID: ${resource.labels.project_id}
22-
# Extracts the environment from the project ID. Ex: mobility-feeds-prod -> prod. Values: prod, qa, dev
23-
- environment: ${text.split(projectID, "-")[2]}
24-
- cloudTaskName: ${"cloud-tasks-2x-rate-queue-" + environment}
22+
- environment: ${sys.get_env("environment")}
23+
# The cloud tasks are sensitive to deletion.
24+
# This is why we need to have this as a parameter set at deploying time.
25+
- cloudTaskName: ${sys.get_env("processing_report_cloud_task_name")}
2526
- serviceAccountEmail: ${"workflows-service-account@mobility-feeds-" + environment + ".iam.gserviceaccount.com"}
2627
- url: ${"https://storage.googleapis.com/" + datasetsBucket + "/" + feedID + "/" + datasetID + "/" + datasetID + ".zip"}
2728
- headers:

0 commit comments

Comments
 (0)