Skip to content

Google Cloud Run

Cloud Run is a managed compute platform that runs containers that are invocable via API requests. It is a serverless service: it abstracts away infrastructure management so we can focus on developing containerized, request-based workflows.

For now, it only contains a function for querying the gcloud CLI to retrieve existing Cloud Run endpoints.

from cloudy.google import run

See Google's Cloud Run Documentation.


get_cloud_run_http_endpoint(service_name, google_config)

Get HTTP endpoint for Cloud Run service from command line.

Example response: testing-first-deployment-qiwkp4xyza-uw.a.run.app

Parameters:

Name Type Description Default
service_name str

the name of the Cloud Run service to retrieve the appplication endpoint from.

required
google_config GoogleCloudConfig

a configs.GoogleCloudConfig object with project, region, and account information.

required

Returns:

Type Description
http_endpoint

the URL to submit Cloud Run jobs to.

Source code in cloudy/google/run.py
def get_cloud_run_http_endpoint(service_name: str, google_config: configs.GoogleCloudConfig) -> str:
    """Get HTTP endpoint for Cloud Run service from command line.

    Example response:  https://testing-first-deployment-qiwkp4xyza-uw.a.run.app

    Args:
      service_name: the name of the Cloud Run service to retrieve the appplication endpoint from.
      google_config: a `configs.GoogleCloudConfig` object with project, region, and account information.

    Returns:
      http_endpoint: the URL to submit Cloud Run jobs to.
    """
    command = "gcloud run services describe {service_name} --platform=managed --region={region}".format(
        service_name=service_name, region=google_config.project_region
    )
    result = subprocess.run(shlex.split(command), stdout=subprocess.PIPE)
    stdout = result.stdout.decode("utf-8")
    http_endpoint = re.search(r"https.*\.run\.app", stdout).group()

    return http_endpoint
Back to top