The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Require a layer bucket for the Lambda logic function driver (#29522)
Etienne3666cf93a542
diff --git a/packages/twenty-docs/developers/self-host/capabilities/setup.mdx b/packages/twenty-docs/developers/self-host/capabilities/setup.mdxindex 4de198c0bc0..276e1153061 100644--- a/packages/twenty-docs/developers/self-host/capabilities/setup.mdx+++ b/packages/twenty-docs/developers/self-host/capabilities/setup.mdx@@ -465,8 +465,11 @@ LOGIC_FUNCTION_LAMBDA_REGION=us-east-1LOGIC_FUNCTION_LAMBDA_ROLE=arn:aws:iam::123456789:role/your-lambda-roleLOGIC_FUNCTION_LAMBDA_ACCESS_KEY_ID=your-access-keyLOGIC_FUNCTION_LAMBDA_SECRET_ACCESS_KEY=your-secret-key+LOGIC_FUNCTION_LAMBDA_LAYER_BUCKET=your-layer-bucket```+The Lambda driver uploads each app's dependency layer to `LOGIC_FUNCTION_LAMBDA_LAYER_BUCKET`, a bucket you own in the same region as your functions. When it is not set, the driver uses your storage bucket (`STORAGE_S3_NAME`). If neither is set, logic functions fail with a configuration error.+**To disable logic functions:**```bashLOGIC_FUNCTION_TYPE=DISABLED # default when NODE_ENV=productiondiff --git a/packages/twenty-server/src/engine/core-modules/logic-function/logic-function-drivers/drivers/lambda/utils/get-lambda-connection-options.util.ts b/packages/twenty-server/src/engine/core-modules/logic-function/logic-function-drivers/drivers/lambda/utils/get-lambda-connection-options.util.tsindex a43fac74ee2..943f5486dc5 100644--- a/packages/twenty-server/src/engine/core-modules/logic-function/logic-function-drivers/drivers/lambda/utils/get-lambda-connection-options.util.ts+++ b/packages/twenty-server/src/engine/core-modules/logic-function/logic-function-drivers/drivers/lambda/utils/get-lambda-connection-options.util.ts@@ -3,6 +3,10 @@ import { fromNodeProviderChain } from '@aws-sdk/credential-providers';import { type TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';import { type LambdaConnectionOptions } from 'src/engine/core-modules/logic-function/logic-function-drivers/drivers/lambda/types/lambda-driver.type';import { getLambdaResourceNamespace } from 'src/engine/core-modules/logic-function/logic-function-drivers/drivers/lambda/utils/get-lambda-resource-namespace.util';+import {+ LogicFunctionException,+ LogicFunctionExceptionCode,+} from 'src/engine/metadata-modules/logic-function/logic-function.exception';export const getLambdaConnectionOptions = (twentyConfigService: TwentyConfigService,@@ -18,11 +22,17 @@ export const getLambdaConnectionOptions = (const subhostingRole = twentyConfigService.get('LOGIC_FUNCTION_LAMBDA_SUBHOSTING_ROLE',);- const s3BucketName = twentyConfigService.get('STORAGE_S3_NAME');const layerBucket =- twentyConfigService.get('LOGIC_FUNCTION_LAMBDA_LAYER_BUCKET') ??- s3BucketName ??- 'twenty-lambda-layer';+ twentyConfigService.get('LOGIC_FUNCTION_LAMBDA_LAYER_BUCKET') ||+ twentyConfigService.get('STORAGE_S3_NAME');++ if (!isNonEmptyString(layerBucket)) {+ throw new LogicFunctionException(+ 'LOGIC_FUNCTION_LAMBDA_LAYER_BUCKET or STORAGE_S3_NAME must be set to use the Lambda logic function driver',+ LogicFunctionExceptionCode.LOGIC_FUNCTION_PLATFORM_EXECUTION_ERROR,+ );+ }+const layerBucketRegion =twentyConfigService.get('LOGIC_FUNCTION_LAMBDA_LAYER_BUCKET_REGION') ??region;diff --git a/packages/twenty-server/src/engine/core-modules/twenty-config/config-variables.ts b/packages/twenty-server/src/engine/core-modules/twenty-config/config-variables.tsindex 26aa97486f6..58d370558ca 100644--- a/packages/twenty-server/src/engine/core-modules/twenty-config/config-variables.ts+++ b/packages/twenty-server/src/engine/core-modules/twenty-config/config-variables.ts@@ -841,7 +841,8 @@ export class ConfigVariables {@ConfigVariablesMetadata({group: ConfigVariablesGroup.LOGIC_FUNCTION_CONFIG,- description: 'S3 bucket for uploading Lambda layer zip files',+ description:+ 'S3 bucket for uploading Lambda layer zip files. Required with the Lambda driver unless STORAGE_S3_NAME is set.',type: ConfigVariableType.STRING,})@ValidateIf(diff --git a/packages/twenty-server/test/integration/logic-function-lambda/utils/switch-to-floci-lambda-driver.util.ts b/packages/twenty-server/test/integration/logic-function-lambda/utils/switch-to-floci-lambda-driver.util.tsindex a40062ba805..f32613b2324 100644--- a/packages/twenty-server/test/integration/logic-function-lambda/utils/switch-to-floci-lambda-driver.util.ts+++ b/packages/twenty-server/test/integration/logic-function-lambda/utils/switch-to-floci-lambda-driver.util.ts@@ -10,6 +10,7 @@ import { LogicFunctionDriverType } from 'src/engine/core-modules/logic-function/const LAMBDA_REGION = 'us-east-1';const LAMBDA_ROLE = 'arn:aws:iam::000000000000:role/twenty-integration-test';+const LAMBDA_LAYER_BUCKET = 'twenty-integration-test-layers';const FLOCI_CREDENTIALS = { accessKeyId: 'test', secretAccessKey: 'test' };export const switchToFlociLambdaDriver =@@ -20,6 +21,7 @@ export const switchToFlociLambdaDriver =LOGIC_FUNCTION_LAMBDA_REGION: LAMBDA_REGION,LOGIC_FUNCTION_LAMBDA_ENDPOINT: floci.endpoint,LOGIC_FUNCTION_LAMBDA_ROLE: LAMBDA_ROLE,+ LOGIC_FUNCTION_LAMBDA_LAYER_BUCKET: LAMBDA_LAYER_BUCKET,LOGIC_FUNCTION_LAMBDA_ACCESS_KEY_ID: FLOCI_CREDENTIALS.accessKeyId,LOGIC_FUNCTION_LAMBDA_SECRET_ACCESS_KEY:FLOCI_CREDENTIALS.secretAccessKey,