0

I have a python cloud run function and I want to get the URL of another cloud run function programatically. I want to avoid hard coding the URL if possible. I need the URL so that I can create a task that has this other functions url as the HTTP url, and then send that task to a task queue.

1
  • Depending of your context... might not work your particular case, but can that 'another cloud function' URL be provided as an environment variable value during the deployment of your main cloud function?
    – al-dann
    Commented Mar 26 at 9:31

1 Answer 1

0

Yes, it is possible to obtain the URL of another Cloud Run function from a Cloud Run function itself.

If you know the name of the Cloud Run function, you can use the Deterministic URL approach. This allows you to determine the URL of the function by simply filling in the necessary details. This information is available even before the function is created.

To get the URL programmatically, you can utilize the Cloud Functions Python library get_function to retrieve the details of another Cloud Run function. However, ensure that the Cloud Run function's identity service account has the Cloud Functions Viewer Role when making the request using this library, as it requires run.services.get or cloudfunctions.functions.get permissions.

1
  • This is very helpful, thank you. Using the Cloud FUnctions Python Library only works if things were deployed as a Cloud Function it seems and not as a cloud run service. In my case I have a cloud run service. Is there a cloud run api that can do this?
    – yambo
    Commented Mar 26 at 23:41

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.