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+
27resource "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
4644resource "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
9081resource "google_service_account" "task_dispatcher" {
0 commit comments