fix: duplicate some Cloud Run IAM grants to functions-python module#1743
Conversation
…comparer to functions-python module
| member = "serviceAccount:${google_service_account.functions_service_account.email}" | ||
| } | ||
|
|
||
| resource "google_cloud_run_service_iam_member" "gtfs_datasets_comparer_invoker" { |
There was a problem hiding this comment.
Is this not affecting the pmtiles builder queue?
|
I think we need the iam permission in both TF files rather than moving the role from one to another. |
We could have them in both. But there would still be a problem since pmtiles_builder_invoker would still refer to a service that is created in python-function. See here |
The issue is that if the permission is not present, the Cloud Task will fail. We had planned(not done yet...) to merge these two TF files so we can avoid this cross-reference issue (completely out of scope in this PR) |
I put back the permissions in batch |
Problem
This was a new error that happened after merging #1737
The
datasets-batch-deployer-devworkflow was failing with:Error 404: Resource 'gtfs-datasets-comparer-dev' of kind 'SERVICE' ... does not exist.
infra/batch/main.tfhad twogoogle_cloud_run_service_iam_memberresources that grantedroles/run.invokeron thepmtiles-builder-devandgtfs-datasets-comparer-devCloud Run services by hardcoded name. These services are deployed by a separate workflow (api-dev/infra/functions-python), so if they don't exist yet — as was the case after renaminggtfs-change-tracker→gtfs-datasets-comparer— Terraform fails trying to set IAM on a non-existent resource.Solution
Moved the two
google_cloud_run_service_iam_memberresources frominfra/batch/main.tfintoinfra/functions-python/main.tf, co-located with thegoogle_cloudfunctions2_functionresources that actually create those services. Usinggoogle_cloudfunctions2_function.X.nameas theservicereference creates an implicit dependency, ensuring the Cloud Run service exists before IAM is applied. This follows the same pattern already used for thetokensandoperations_apifunctions.Also removed the now-unused
function_pmtiles_builder_configandfunction_gtfs_datasets_comparer_configlocals frominfra/batch/main.tf.Please make sure these boxes are checked before submitting your pull request - thanks!
./scripts/api-tests.shto make sure you didn't break anything