From 247a37650c26a98afffb8122240ea01172787080 Mon Sep 17 00:00:00 2001 From: steveoh Date: Wed, 10 Jul 2024 11:26:25 -0700 Subject: [PATCH] fix(developer): set v1 function settings with v1 methods --- src/developer/functions/index.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/developer/functions/index.js b/src/developer/functions/index.js index d90a4ab9..70a6bc8c 100644 --- a/src/developer/functions/index.js +++ b/src/developer/functions/index.js @@ -1,14 +1,18 @@ import { debug } from 'firebase-functions/logger'; -import { auth } from 'firebase-functions/v1'; // v2 does not support auth triggers as of july/23 +import { runWith } from 'firebase-functions/v1'; import { https, setGlobalOptions } from 'firebase-functions/v2'; import { safelyInitializeApp } from './firebase.js'; safelyInitializeApp(); +const serviceAccount = `firestore-function-sa@${process.env.GCLOUD_PROJECT}.iam.gserviceaccount.com`; +const vpcConnector = 'memorystore-connector'; +const vpcConnectorEgressSettings = 'PRIVATE_RANGES_ONLY'; + setGlobalOptions({ - serviceAccount: `firestore-function-sa@${process.env.GCLOUD_PROJECT}.iam.gserviceaccount.com`, - vpcConnector: 'memorystore-connector', - vpcConnectorEgressSettings: 'PRIVATE_RANGES_ONLY', + serviceAccount, + vpcConnector, + vpcConnectorEgressSettings, }); const cors = [ @@ -29,8 +33,12 @@ const cors = [ * @param {any} async(user - The user details from the OIDC flow from Utahid. * @returns {bool} - The true or false result of the create user method. */ -export const onCreateUser = auth - .user({ +export const onCreateUser = runWith({ + serviceAccount, + vpcConnector, + vpcConnectorEgressSettings, +}) + .auth.user({ secrets: ['SENDGRID_API_KEY'], }) .onCreate(async (user) => {