Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Predictable URL for cloud run services?

We're setting up some ci/cd workflows with cloud run + pub/sub, with terraflow used to provision the initial services, but one thing that's causing us some complexity is the cloud run URLs do not appear to be "predictable" -- the hash, specifically.  Is there some way to either force the hash to be something predictable, or the entire URL?

0 1 1,149
1 REPLY 1

Using gcloud run services describe on the cloud run service name got it.  I was able to use something like this in my cloud build script:
 
SERVICE_URL=$(gcloud run services describe $CLOUD_RUN_SERVICE_NAME \
          --project $PROJECT_ID \
          --region $CLOUD_RUN_RUN_LOCATION \
          --format "value(status.url)")
        echo $SERVICE_URL
 
Where $CLOUD_RUN_SERVICE_NAME is the cloud service name, project ID the project ID it is running in, $CLOUD_RUN_RUN_LOCATION the location it was deployed (e.g. us-west1).  --format "value(status.url)" returns the URL of the service for use in other steps!
 
The forum wouldn't let me use double "$" but if you use that in a cloudbuild.yaml you'll need to double "$" every variable except $PROJECT_ID, and pre-load the variables as environment variables.