Project Number is used instead of project_id in run/jobs_execute_jobs_on_schedule/main.tf
philip-harvey opened this issue · comments
TL;DR
Incorrect code:
uri = "https://${google_cloud_run_v2_job.default.location}-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/${data.google_project.project.number}/jobs/${google_cloud_run_v2_job.default.name}:run"
Corrected code:
uri = "https://${google_cloud_run_v2_job.default.location}-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/${data.google_project.project.project_id}/jobs/${google_cloud_run_v2_job.default.name}:run"
Expected behavior
Creating the trigger would work and would show up under triggers
Observed behavior
Trigger is created and works using project number but doesn't show as a configured trigger.
When created via the GUI project_id is used in the trigger, and when you use project_id in the trigger in Terraform then it works correctly
Terraform Configuration
https://github.com/terraform-google-modules/terraform-docs-samples/blob/902a30c60089ac90b8afce0f5985f067c0ae0f66/run/jobs_execute_jobs_on_schedule/main.tf#L113C131-L113C165
Terraform Version
Any
Additional information
No response
Hi @philip-harvey, thank you for your request. Let me check it.
Hi @iennae PTAL. Thanks.
Last time when tested, I found the provided code seems to be working.
From Cloud Run API: "The full name of the Job. Format: projects/{project}/locations/{location}/jobs/{job}, where {project} can be project id or number"
https://cloud.google.com/run/docs/reference/rest/v2/projects.locations.jobs/run
Trying the sample myself, the Scheduler Job is created and appears in the console, and the HTTP URL correctly hits the Cloud Run Job created in the same project.
Aside: this sample could be cleaned up to clarify the project id/number usage, as well as minor style guide inconsistencies, but the same works as written.