Enabling tenant isolation for Lambda functions
To activate tenant isolation mode, create a new Lambda function. You cannot enable tenant isolation on existing functions.
Topics
Enabling tenant isolation (console)
To create a Lambda function using the console
Open the Functions page
of the Lambda console. -
Choose Create function.
-
Select Author from scratch.
-
In the Basic information pane, for Function name, enter
.image-analysis -
For Runtime, choose any of the supported Lambda runtimes.
-
Under additional configurations, Tenant isolation mode, select Enable.
-
Review your settings, and choose Create function.
Enabling tenant isolation (AWS CLI)
Create function with tenant isolation
When creating a new function using the CLI, add the --tenancy-config
'{"TenantIsolationMode": "PER_TENANT"}' option to your create-function request. Example:
aws lambda create-function \ --function-nameimage-analysis\ --runtimenodejs22.x\ --zip-file fileb://image-analysis-function.zip \ --handler image-analysis-function.handler \ --rolearn:aws:iam:123456789012:role/execution-role\ --tenancy-config '{"TenantIsolationMode": "PER_TENANT"}'
Enabling tenant isolation (API)
To enable tenant isolation using the Lambda API
-
Create a new function with tenant isolation enabled by using the CreateFunction API action with the
TenancyConfigparameter. -
Confirm that tenant isolation is enabled for the function by using the GetFunctionConfiguration action. If the response shows that
TenantIsolationModeisPER_TENANT, then tenant isolation is enabled for the function:"TenancyConfig": { "TenantIsolationMode": "PER_TENANT" }
Invoke the function version with the Invoke action. For more information, see Invoking Lambda functions with tenant isolation.
Enabling tenant isolation (CloudFormation)
The following CloudFormation template creates a new Lambda function with tenant isolation enabled:
MyLambdaFunction: Type: AWS::Lambda::Function Properties: FunctionName:my-sample-python-lambdaRuntime:python3.13Role: !GetAtt LambdaExecutionRole.Arn Handler: index.lambda_handler TenancyConfig: TenantIsolationMode: PER_TENANT Code: ZipFile: | import json def lambda_handler(event, context): return { 'statusCode':200, 'body': json.dumps(f'Hello from Lambda! Tenant-ID: {context.tenant_id}') } Timeout:10MemorySize:128