Skip to content
v2.274.0

FileSystem Class ​

Represents the filesystem for the Lambda function.

Example ​

ts
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as efs from 'aws-cdk-lib/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_LATEST,
  handler: 'index.handler',
  code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
  vpc,
});

Properties ​

the FileSystem configurations for the Lambda function.

Methods ​

fromEfsAccessPoint(ap: IAccessPoint, mountPath: string): FileSystem // chainable@staticmethod def from_efs_access_point(ap: IAccessPoint, mount_path: str) -> FileSystempublic static FileSystem fromEfsAccessPoint(IAccessPoint ap, String mountPath)public static FileSystem FromEfsAccessPoint(IAccessPoint ap, string mountPath)func FromEfsAccessPoint(Ap IAccessPoint, MountPath *string) FileSystemstatic#
mount the filesystem from Amazon EFS.
2 parameters

Parameters

  • apapapapAp — the Amazon EFS access point.
  • mountPathmount_pathmountPathmountPathMountPath — the target path in the lambda runtime environment.
fromS3FilesAccessPoint(ap: IAccessPointRef, mountPath: string, options?: S3FilesOptions): FileSystem // chainable@staticmethod def from_s3_files_access_point(ap: IAccessPointRef, mount_path: str, options: typing.Optional[S3FilesOptions] = None) -> FileSystempublic static FileSystem fromS3FilesAccessPoint(IAccessPointRef ap, String mountPath, S3FilesOptions options)public static FileSystem FromS3FilesAccessPoint(IAccessPointRef ap, string mountPath, S3FilesOptions? options = null)func FromS3FilesAccessPoint(Ap IAccessPointRef, MountPath *string, Options S3FilesOptions) FileSystemstatic#
Mount the filesystem from Amazon S3 Files.
3 parameters

Parameters

  • apapapapAp — the S3 Files access point.
  • mountPathmount_pathmountPathmountPathMountPath — the target path in the lambda runtime environment.
  • optionsoptionsoptionsoptionsOptions — optional S3 Files mount options such as DirectS3Read mode.