launchflow.gcp.cloud_run

CloudRun

1
class CloudRun(Service)

A service hosted on GCP Cloud Run.

Example usage:

1
import launchflow as lf
2
3
service = lf.gcp.CloudRun("my-service", cpu=4)

NOTE: This will create the following infrastructure in your GCP project:

__init__

1
def __init__(
2
name: str,
3
dockerfile: str = "Dockerfile",
4
build_directory: str = ".",
5
build_ignore: List[str] = [],
6
region: Optional[str] = None,
7
cpu: Optional[int] = None,
8
memory: Optional[str] = None,
9
port: Optional[int] = None,
10
publicly_accessible: Optional[bool] = None,
11
min_instance_count: Optional[int] = None,
12
max_instance_count: Optional[int] = None,
13
max_instance_request_concurrency: Optional[int] = None,
14
invokers: Optional[List[str]] = None,
15
custom_audiences: Optional[List[str]] = None,
16
ingress: Optional[Literal[
17
"INGRESS_TRAFFIC_ALL",
18
"INGRESS_TRAFFIC_INTERNAL_ONLY",
19
"INGRESS_TRAFFIC_INTERNAL_LOAD_BALANCER",
20
]] = None
21
) -> None

Creates a new Cloud Run service.

Args:

  • name: The name of the service.
  • build_directory: The directory to build the service from. This should be a relative path from the project root where your launchflow.yaml is defined.
  • dockerfile: The Dockerfile to use for building the service. This should be a relative path from the build_directory.
  • build_ignore: A list of files to ignore when building the service. This can be in the same syntax you would use for a .gitignore.
  • region: The region to deploy the service to.
  • cpu: The number of CPUs to allocate to each instance of the service.
  • memory: The amount of memory to allocate to each instance of the service.
  • port: The port the service listens on.
  • publicly_accessible: Whether the service is publicly accessible. Defaults to True.
  • min_instance_count: The minimum number of instances to keep running.
  • max_instance_count: The maximum number of instances to run.
  • max_instance_request_concurrency: The maximum number of requests each instance can handle concurrently.
  • invokers: A list of invokers that can access the service.
  • custom_audiences: A list of custom audiences that can access the service. See: https://cloud.google.com/run/docs/configuring/custom-audiences
  • ingress: The ingress settings for the service. See: https://cloud.google.com/run/docs/securing/ingress