Skip to main content

speculateServiceName()

EXPERIMENTAL

Cloud Run is in Alpha, which means APIs may change in any version and documentation is not yet finished. See the changelog to stay up to date with breaking changes.

Speculate the name of the Cloud Run service that will be created by deployService() or its CLI equivalent, npx remotion cloudrun services deploy. This could be useful in cases when the configuration of the Cloud Run service is known in advance, and the name of the service is needed.

If you are not sure whether a service exists, use getServiceInfo() and catch the error that gets thrown if it does not exist.

If you want to get a list of deployed services, use getServices() instead.

Service name pattern

The service name depends on the following parameters:

  • Remotion version
  • Memory Limit
  • CPU Limit
  • Timeout in seconds

The name of the service resembles the following pattern:

remotion--3-3-96--mem2gi--cpu1-0--t-1900
^^^^^^ ^^^ ^^^ ^^^
| | | |-- Timeout in seconds
| | |----------- Cpu limit
| |------------------- Memory limit
|--------------------------- Remotion version with dots replaced by dashes
remotion--3-3-96--mem2gi--cpu1-0--t-1900
^^^^^^ ^^^ ^^^ ^^^
| | | |-- Timeout in seconds
| | |----------- Cpu limit
| |------------------- Memory limit
|--------------------------- Remotion version with dots replaced by dashes

Example

ts
import { speculateServiceName } from "@remotion/cloudrun";
 
const speculatedServiceName = speculateServiceName({
memoryLimit: "2Gi",
cpuLimit: "2",
timeoutSeconds: 300,
});
 
console.log(speculatedServiceName); // remotion--3-3-96--mem2gi--cpu2-0--t-300
ts
import { speculateServiceName } from "@remotion/cloudrun";
 
const speculatedServiceName = speculateServiceName({
memoryLimit: "2Gi",
cpuLimit: "2",
timeoutSeconds: 300,
});
 
console.log(speculatedServiceName); // remotion--3-3-96--mem2gi--cpu2-0--t-300

Arguments

An object with the following properties:

memoryLimit

The upper bound on the amount of RAM that the Cloud Run service can consume.

cpuLimit

The maximum number of CPU cores that the Cloud Run service can use to process requests.

timeoutSeconds

The timeout that has been assigned to the Cloud Run service.

Return value

A string with the speculated name of the service.

See also