🎥 Make videos programmatically with React
permissions file now includes reason
Matt McGillivray0985d1b5113f
diff --git a/packages/cloudrun/package.json b/packages/cloudrun/package.jsonindex 914fb2f8ea..7167848238 100644--- a/packages/cloudrun/package.json+++ b/packages/cloudrun/package.json@@ -39,7 +39,8 @@"exports": {"./package.json": "./package.json",".": "./dist/index.js",- "./regions": "./dist/regions.js"+ "./regions": "./dist/regions.js",+ "./permissions.json": "./dist/shared/sa-permissions.json"},"typesVersions": {">=1.0": {diff --git a/packages/cloudrun/src/api/iam-validation/testPermissions.ts b/packages/cloudrun/src/api/iam-validation/testPermissions.tsindex 68780207f1..88817a1b67 100644--- a/packages/cloudrun/src/api/iam-validation/testPermissions.ts+++ b/packages/cloudrun/src/api/iam-validation/testPermissions.ts@@ -38,9 +38,13 @@ export const testPermissions = async ());+ const permissionList: string[] = saPermissions.list.map(+ (permission: {name: string; reason: string}) => permission.name+ );+const response = await resourceManagerClient.testIamPermissions({resource: `projects/${process.env.REMOTION_GCP_PROJECT_ID}`,- permissions: saPermissions.list,+ permissions: permissionList,});const returnedPermissions = response[0].permissions;@@ -53,13 +57,13 @@ export const testPermissions = async (const results: TestResult[] = [];- saPermissions.list.forEach((permission: string) => {- if (returnedPermissions.includes(permission)) {- const thisResult = {decision: true, permissionName: permission};+ saPermissions.list.forEach((permission: {name: string; reason: string}) => {+ if (returnedPermissions.includes(permission.name)) {+ const thisResult = {decision: true, permissionName: permission.name};results.push(thisResult);params?.onTest(thisResult);} else {- const thisResult = {decision: false, permissionName: permission};+ const thisResult = {decision: false, permissionName: permission.name};results.push(thisResult);params?.onTest(thisResult);}diff --git a/packages/cloudrun/src/gcpInstaller/gcpInstaller.tar b/packages/cloudrun/src/gcpInstaller/gcpInstaller.tarindex 57dbe0f74a..2484815d03 100644Binary files a/packages/cloudrun/src/gcpInstaller/gcpInstaller.tar and b/packages/cloudrun/src/gcpInstaller/gcpInstaller.tar differdiff --git a/packages/cloudrun/src/gcpInstaller/main.tf b/packages/cloudrun/src/gcpInstaller/main.tfindex af24e395fc..6a5a000378 100644--- a/packages/cloudrun/src/gcpInstaller/main.tf+++ b/packages/cloudrun/src/gcpInstaller/main.tf@@ -25,7 +25,8 @@ data "local_file" "permissions" {}locals {- cloudrun-permissions = jsondecode(data.local_file.permissions.content)+ raw-permissions = jsondecode(data.local_file.permissions.content)+ cloudrun-permissions = [for i in local.raw_permissions.list : i.name]service-account-email = "remotion-sa@${var.project_id}.iam.gserviceaccount.com"}diff --git a/packages/cloudrun/src/shared/sa-permissions.json b/packages/cloudrun/src/shared/sa-permissions.jsonindex adc5694e85..cd0c03cd45 100644--- a/packages/cloudrun/src/shared/sa-permissions.json+++ b/packages/cloudrun/src/shared/sa-permissions.json@@ -1,20 +1,60 @@{"list": [- "iam.serviceAccounts.actAs",- "run.operations.get",- "run.routes.invoke",- "run.services.create",- "run.services.get",- "run.services.delete",- "run.services.list",- "run.services.update",- "storage.buckets.create",- "storage.buckets.get",- "storage.buckets.list",- "storage.objects.create",- "storage.objects.delete",- "storage.objects.list",- "run.services.getIamPolicy",- "run.services.setIamPolicy"+ {+ "name": "iam.serviceAccounts.actAs",+ "reason": "When deploying, act as the default service account, which will grant further permissions required during deployment."+ },+ {+ "name": "run.operations.get",+ "reason": "Required during deployment to confirm that deployment was successful."+ },+ {+ "name": "run.routes.invoke",+ "reason": "Invoke the deployed Cloud Run services to perform a render."+ },+ {+ "name": "run.services.create",+ "reason": "Deploy new, and edit existing, Cloud Run services."+ },+ {+ "name": "run.services.get",+ "reason": ""+ },+ {+ "name": "run.services.delete",+ "reason": ""+ },+ {+ "name": "run.services.list",+ "reason": "Get a list of existing Cloud Run services, to ensure no unintended overwriting."+ },+ {+ "name": "run.services.update",+ "reason": "Update a Cloud Run service, for example providing it with more memory or CPU."+ },+ {+ "name": "storage.buckets.create",+ "reason": "Create the storage bucket to store the bundled site and render output."+ },+ {+ "name": "storage.buckets.get",+ "reason": ""+ },+ {+ "name": "storage.buckets.list",+ "reason": "Get a list of existing Cloud Storage resources, to ensure no unintended overwriting of storage buckets."+ },+ {+ "name": "storage.objects.create",+ "reason": "Create new objects in storage. This could be bundled sites, or renders, or logs."+ },+ {+ "name": "storage.objects.delete",+ "reason": ""+ },+ {+ "name": "storage.objects.list",+ "reason": ""+ }]}\ No newline at end of filediff --git a/packages/docs/components/cloudrun/sa-permissions.tsx b/packages/docs/components/cloudrun/sa-permissions.tsxnew file mode 100644index 0000000000..433f61c2c8--- /dev/null+++ b/packages/docs/components/cloudrun/sa-permissions.tsx@@ -0,0 +1,43 @@+import React from "react";++const permissionsJson = require('@remotion/cloudrun/permissions.json');++type Permission = {+ name: string;+ reason: string;+}++export const SAPermissionList: React.FC = () => {+ console.log(permissionsJson.list)+ return (+ <div>+ <pre>{permissionsJson.list.map((permission: Permission) => {+ return `${permission.name}\n`+ })}</pre>+ </div>+ );+};++export const SAPermissionTable: React.FC = () => {+ console.log(permissionsJson.list)+ return (+ <table>+ <tr>+ <th>+ Permission+ </th>+ <th>+ Reason+ </th>+ </tr>+ {permissionsJson.list.map((permission: Permission) => {+ return <tr key={permission.name}>+ <td>+ <code>{permission.name}</code>+ </td>+ <td><code>{permission.reason}</code></td>+ </tr>+ })}+ </table>+ );+};diff --git a/packages/docs/docs/cloudrun/permissions.md b/packages/docs/docs/cloudrun/permissions.mdnew file mode 100644index 0000000000..2ae0eb990f--- /dev/null+++ b/packages/docs/docs/cloudrun/permissions.md@@ -0,0 +1,49 @@+---+image: /generated/articles-docs-cloudrun-permissions.png+sidebar_label: Permissions+title: Permissions+crumb: "Cloud Run"+---++import {SAPermissionList, SAPermissionTable} from '../../components/cloudrun/sa-permissions.tsx';++This document describes the necessary permissions for Remotion Cloud Run and explains to those interested why the permissions are necessary.++For a step by step guide on how to set up permissions, [follow the setup guide](/docs/cloudrun/setup).++## Service Account permissions++This policy should be assigned to the **Remotion Service Account**. Following the automated setup, this is achieved by creating a custom role with the title _Remotion API Service Account_, and assigning that role to the Remotion Service Account.++To view and manually edit roles in your GCP project, go to the [Roles page within IAM admin](https://console.cloud.google.com/iam-admin/roles).++To view and manually edit permissions/roles assigned to Users or Service Accounts in your GCP project, go to the [IAM page within IAM Admin](https://console.cloud.google.com/iam-admin/iam).++<details>+<summary>Show full Remotion API Service Account permissions list for the latest Remotion Cloud Run version.+</summary>+<SAPermissionList />+</details>++:::info+You can always get the suitable permission file for your Remotion Cloud Run version by typing `npx remotion cloudrun permissions`.+:::++The following table is a breakdown of why Remotion Cloud Run requires the permissions it does.++<SAPermissionTable />++## Validation++There are two ways in which you can test if the permissions for the service account have been correctly set up. Either you execute the following command:++```bash+npx remotion cloudrun permissions+```++or if you want to validate it programmatically, using the [`testPermissions()`](/docs/cloudrun/testpermissions) function.++## See also++- [Set up guide](/docs/cloudrun/setup)+- [`testPermissions()`](/docs/cloudrun/testpermissions)diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.jsindex e08f1e2dce..a59112a2bb 100644--- a/packages/docs/sidebars.js+++ b/packages/docs/sidebars.js@@ -535,6 +535,7 @@ module.exports = {},items: ["cloudrun/setup",+ "cloudrun/permissions","cloudrun/generate-env","cloudrun/region-selection","cloudrun/faq",