Skip to main content

testPermissions()

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.

Makes a call to the Test Iam Permissions method of the Resource Manager API in GCP, which returns the list of permissions the Service Account has on the GCP Project. This is then validated against the list of permissions required for the version of Remotion.

The CLI equivalent is npx remotion cloudrun permissions.

The function does not reject with an error if a permission is missing, rather the missing permission is indicated in the return value.

Example

ts
import { testPermissions } from "@remotion/cloudrun";
 
const { results } = await testPermissions();
 
for (const result of results) {
console.log(result.decision); // "allowed"
console.log(result.permissionName); // "iam.serviceAccounts.actAs"
}
ts
import { testPermissions } from "@remotion/cloudrun";
 
const { results } = await testPermissions();
 
for (const result of results) {
console.log(result.decision); // "allowed"
console.log(result.permissionName); // "iam.serviceAccounts.actAs"
}

Arguments

An object with the following property:

onTest?

optional

A callback function that gets called every time a new test has been executed. This allows you to react to new test results coming in much faster than waiting for the return value of the function. Example:

ts
import { testPermissions } from "@remotion/cloudrun";
 
const { results } = await testPermissions({
onTest: (result) => {
console.log(result.decision); // "allowed"
console.log(result.permissionName); // "iam.serviceAccounts.actAs"
},
});
ts
import { testPermissions } from "@remotion/cloudrun";
 
const { results } = await testPermissions({
onTest: (result) => {
console.log(result.decision); // "allowed"
console.log(result.permissionName); // "iam.serviceAccounts.actAs"
},
});

Return value

An array of objects containing simulation results of each necessary permission. The objects contain the following keys:

decision

Either true or false.

permissionName

The identifier of the required permission. See the Permissions page to see a list of required permissions.

See also