From 0711c65bcbdbe98d2cfb7a16fd4e29a3ed11a436 Mon Sep 17 00:00:00 2001 From: Thomas Bouldin Date: Mon, 16 Dec 2024 13:15:43 -0800 Subject: [PATCH] Setting service account also changes build service account --- src/gcp/cloudfunctionsv2.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gcp/cloudfunctionsv2.ts b/src/gcp/cloudfunctionsv2.ts index 6d17c607bbc..5aaf5fa0dc2 100644 --- a/src/gcp/cloudfunctionsv2.ts +++ b/src/gcp/cloudfunctionsv2.ts @@ -49,6 +49,7 @@ export interface BuildConfig { source: Source; sourceToken?: string; environmentVariables: Record; + serviceAccount?: string; // Output only build?: string; @@ -499,6 +500,9 @@ export function functionFromEndpoint(endpoint: backend.Endpoint): InputCloudFunc }, serviceConfig: {}, }; + if (endpoint.serviceAccount) { + gcfFunction.buildConfig.serviceAccount = `projects/${endpoint.project}/serviceAccounts/${endpoint.serviceAccount}`; + } proto.copyIfPresent(gcfFunction, endpoint, "labels"); proto.copyIfPresent( @@ -515,6 +519,7 @@ export function functionFromEndpoint(endpoint: backend.Endpoint): InputCloudFunc "serviceAccountEmail", "serviceAccount", ); + // Memory must be set because the default value of GCF gen 2 is Megabytes and // we use mebibytes const mem = endpoint.availableMemoryMb || backend.DEFAULT_MEMORY;