class FileSystem
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.Lambda.FileSystem |
Java | software.amazon.awscdk.services.lambda.FileSystem |
Python | aws_cdk.aws_lambda.FileSystem |
TypeScript (source) | @aws-cdk/aws-lambda » FileSystem |
Represents the filesystem for the Lambda function.
Example
import * as ec2 from '@aws-cdk/aws-ec2';
import * as efs from '@aws-cdk/aws-efs';
// create a new VPC
const vpc = new ec2.Vpc(this, 'VPC');
// create a new Amazon EFS filesystem
const fileSystem = new efs.FileSystem(this, 'Efs', { vpc });
// create a new access point from the filesystem
const accessPoint = fileSystem.addAccessPoint('AccessPoint', {
// set /export/lambda as the root of the access point
path: '/export/lambda',
// as /export/lambda does not exist in a new efs filesystem, the efs will create the directory with the following createAcl
createAcl: {
ownerUid: '1001',
ownerGid: '1001',
permissions: '750',
},
// enforce the POSIX identity so lambda function will access with this identity
posixUser: {
uid: '1001',
gid: '1001',
},
});
const fn = new lambda.Function(this, 'MyLambda', {
// mount the access point to /mnt/msg in the lambda runtime environment
filesystem: lambda.FileSystem.fromEfsAccessPoint(accessPoint, '/mnt/msg'),
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
vpc,
});
Initializer (protected)
super(config: FileSystemConfig)
Parameters
- config
File
— the FileSystem configurations for the Lambda function.System Config
Properties
Name | Type | Description |
---|---|---|
config | File | the FileSystem configurations for the Lambda function. |
config
Type:
File
the FileSystem configurations for the Lambda function.
Methods
Name | Description |
---|---|
static from | mount the filesystem from Amazon EFS. |
EfsAccessPoint(ap, mountPath)
static frompublic static fromEfsAccessPoint(ap: IAccessPoint, mountPath: string): FileSystem
Parameters
- ap
IAccess
— the Amazon EFS access point.Point - mountPath
string
— the target path in the lambda runtime environment.
Returns
mount the filesystem from Amazon EFS.