Class FileSystem

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.lambda.FileSystem
All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.139.0 (build 26a6b54)", date="2026-09-17T14:54:06.833Z") @Stability(Stable) public class FileSystem extends software.amazon.jsii.JsiiObject
Represents the filesystem for the Lambda function.

Example:

 import software.amazon.awscdk.services.ec2.*;
 import software.amazon.awscdk.services.efs.*;
 // create a new VPC
 Vpc vpc = new Vpc(this, "VPC");
 // create a new Amazon EFS filesystem
 FileSystem fileSystem = FileSystem.Builder.create(this, "Efs").vpc(vpc).build();
 // create a new access point from the filesystem
 AccessPoint accessPoint = fileSystem.addAccessPoint("AccessPoint", AccessPointOptions.builder()
         // 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(Acl.builder()
                 .ownerUid("1001")
                 .ownerGid("1001")
                 .permissions("750")
                 .build())
         // enforce the POSIX identity so lambda function will access with this identity
         .posixUser(PosixUser.builder()
                 .uid("1001")
                 .gid("1001")
                 .build())
         .build());
 Function fn = Function.Builder.create(this, "MyLambda")
         // mount the access point to /mnt/msg in the lambda runtime environment
         .filesystem(FileSystem.fromEfsAccessPoint(accessPoint, "/mnt/msg"))
         .runtime(Runtime.NODEJS_LATEST)
         .handler("index.handler")
         .code(Code.fromAsset(join(__dirname, "lambda-handler")))
         .vpc(vpc)
         .build();
 
  • Constructor Details

    • FileSystem

      protected FileSystem(software.amazon.jsii.JsiiObjectRef objRef)
    • FileSystem

      protected FileSystem(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • FileSystem

      @Stability(Stable) protected FileSystem(@NotNull FileSystemConfig config)
      Parameters:
      config - the FileSystem configurations for the Lambda function. This parameter is required.
  • Method Details

    • fromEfsAccessPoint

      @Stability(Stable) @NotNull public static FileSystem fromEfsAccessPoint(@NotNull IAccessPoint ap, @NotNull String mountPath)
      mount the filesystem from Amazon EFS.

      Parameters:
      ap - the Amazon EFS access point. This parameter is required.
      mountPath - the target path in the lambda runtime environment. This parameter is required.
    • fromS3FilesAccessPoint

      @Stability(Stable) @NotNull public static FileSystem fromS3FilesAccessPoint(@NotNull IAccessPointRef ap, @NotNull String mountPath, @Nullable S3FilesOptions options)
      Mount the filesystem from Amazon S3 Files.

      Parameters:
      ap - the S3 Files access point. This parameter is required.
      mountPath - the target path in the lambda runtime environment. This parameter is required.
      options - optional S3 Files mount options such as DirectS3Read mode.
    • fromS3FilesAccessPoint

      @Stability(Stable) @NotNull public static FileSystem fromS3FilesAccessPoint(@NotNull IAccessPointRef ap, @NotNull String mountPath)
      Mount the filesystem from Amazon S3 Files.

      Parameters:
      ap - the S3 Files access point. This parameter is required.
      mountPath - the target path in the lambda runtime environment. This parameter is required.
    • getConfig

      @Stability(Stable) @NotNull public FileSystemConfig getConfig()
      the FileSystem configurations for the Lambda function.