Skip to content

Commit 89e2426

Browse files
authored
fix: re-create publishing task queue (#1021)
1 parent 4f343da commit 89e2426

File tree

4 files changed

+61
-72
lines changed

4 files changed

+61
-72
lines changed

terraform/.terraform.lock.hcl

Lines changed: 27 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

terraform/cloud_run_api.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ locals {
2424
"EMAIL_FROM" = "help@${var.domain_name}"
2525
"EMAIL_FROM_NAME" = var.email_from_name
2626

27-
"PUBLISH_QUEUE_ID" = google_cloud_tasks_queue.publishing_tasks.id
28-
"NPM_TARBALL_BUILD_QUEUE_ID" = google_cloud_tasks_queue.npm_tarball_build_tasks.id
27+
"PUBLISH_QUEUE_ID" = "projects/${var.gcp_project}/locations/us-central1/queues/${local.publishing_tasks_queue_name}"
28+
"NPM_TARBALL_BUILD_QUEUE_ID" = "projects/${var.gcp_project}/locations/us-central1/queues/${local.npm_tarball_build_tasks_queue_name}"
2929

3030
"LOGS_BIGQUERY_TABLE_ID" = "${data.google_bigquery_dataset.default.dataset_id}._Default"
3131
"GCP_PROJECT_ID" = var.gcp_project

terraform/providers.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ terraform {
88
required_providers {
99
google = {
1010
source = "hashicorp/google"
11-
version = ">= 5.0.0, < 6.0.0"
11+
version = ">= 6.0.0, < 7.0.0"
1212
}
1313
}
1414
}

terraform/queues.tf

Lines changed: 31 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
// Copyright 2024 the JSR authors. All rights reserved. MIT license.
2+
locals {
3+
publishing_tasks_queue_name = var.gcp_project == "deno-registry3-prod" ? "publishing-tasks3" : "publishing-tasks"
4+
npm_tarball_build_tasks_queue_name = "npm-tarball-build-tasks2"
5+
}
6+
27
resource "google_cloud_tasks_queue" "publishing_tasks" {
3-
name = "publishing-tasks"
8+
name = local.publishing_tasks_queue_name
49
location = "us-central1"
510

611
retry_config {
@@ -22,29 +27,22 @@ resource "google_cloud_tasks_queue" "publishing_tasks" {
2227
prevent_destroy = true
2328
}
2429

25-
# TODO: Set up queue-level routing from terraform.
26-
# Blocked on: https://github.com/hashicorp/terraform-provider-google/issues/15022
27-
# For now, manually set up queue level routing with these settings:
28-
# {
29-
# "httpTarget": {
30-
# "uriOverride": {
31-
# "host": "${stripPrefix("https://", google_cloud_run_v2_service.registry_api_tasks.uri)}",
32-
# "pathOverride": { "path": "/tasks/publish" }
33-
# },
34-
# "oidcToken": {
35-
# "serviceAccountEmail": "${google_service_account.task_dispatcher.email}"
36-
# }
37-
# }
38-
# }
39-
# The command to do this:
40-
# curl -X PATCH -d @./data.json -i \
41-
# -H "Authorization: Bearer $(gcloud auth print-access-token)" \
42-
# -H "Content-Type: application/json" \
43-
# "https://cloudtasks.googleapis.com/v2beta3/projects/$PROJECT_ID/locations/us-central1/queues/publishing-tasks?updateMask=httpTarget.uriOverride,httpTarget.oidcToken"
30+
http_target {
31+
uri_override {
32+
host = trimprefix(google_cloud_run_v2_service.registry_api_tasks.uri, "https://")
33+
path_override {
34+
path = "/tasks/publish"
35+
}
36+
}
37+
38+
oidc_token {
39+
service_account_email = google_service_account.task_dispatcher.email
40+
}
41+
}
4442
}
4543

4644
resource "google_cloud_tasks_queue" "npm_tarball_build_tasks" {
47-
name = "npm-tarball-build-tasks2"
45+
name = local.npm_tarball_build_tasks_queue_name
4846
location = "us-central1"
4947

5048
retry_config {
@@ -66,25 +64,18 @@ resource "google_cloud_tasks_queue" "npm_tarball_build_tasks" {
6664
prevent_destroy = true
6765
}
6866

69-
# TODO: Set up queue-level routing from terraform.
70-
# Blocked on: https://github.com/hashicorp/terraform-provider-google/issues/15022
71-
# For now, manually set up queue level routing with these settings:
72-
# {
73-
# "httpTarget": {
74-
# "uriOverride": {
75-
# "host": "${stripPrefix("https://", google_cloud_run_v2_service.registry_api_tasks.uri)}",
76-
# "pathOverride": { "path": "/tasks/npm_tarball_build" }
77-
# },
78-
# "oidcToken": {
79-
# "serviceAccountEmail": "${google_service_account.task_dispatcher.email}"
80-
# }
81-
# }
82-
# }
83-
# The command to do this:
84-
# curl -X PATCH -d @./data.json -i \
85-
# -H "Authorization: Bearer $(gcloud auth print-access-token)" \
86-
# -H "Content-Type: application/json" \
87-
# "https://cloudtasks.googleapis.com/v2beta3/projects/$PROJECT_ID/locations/us-central1/queues/npm-tarball-build-tasks2?updateMask=httpTarget.uriOverride,httpTarget.oidcToken"
67+
http_target {
68+
uri_override {
69+
host = trimprefix(google_cloud_run_v2_service.registry_api_tasks.uri, "https://")
70+
path_override {
71+
path = "/tasks/npm_tarball_build"
72+
}
73+
}
74+
75+
oidc_token {
76+
service_account_email = google_service_account.task_dispatcher.email
77+
}
78+
}
8879
}
8980

9081
resource "google_service_account" "task_dispatcher" {

0 commit comments

Comments
 (0)