# FileSystem

The Elastic File System implementation of IFileSystem.

It creates a new, empty file system in Amazon Elastic File System (Amazon EFS).
It also creates mount target (AWS::EFS::MountTarget) implicitly to mount the
EFS file system on an Amazon Elastic Compute Cloud (Amazon EC2) instance or another resource.

Extends: Construct › Resource › FileSystem
Implements: IResource, IConnectable, IFileSystem, IResourceWithPolicy, IResourceWithPolicyV2, IEnvironmentAware, IFileSystemRef, IConstruct, IDependable

- CloudFormation: [`AWS::EFS::FileSystem`](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-efs-filesystem.html)
- L1 type: [`CfnFileSystem`](/cdk/api/v2/docs/aws-cdk-lib.aws_efs.CfnFileSystem.html)
- Source: [`aws-efs/lib/efs-file-system.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-efs/lib/efs-file-system.ts#L735)
- Type last changed: v2.234.0 · 8 Jan 2026

## Example

```ts
import * as iam from 'aws-cdk-lib/aws-iam';

const role = new iam.Role(this, 'ClientRole', {
  assumedBy: new iam.AnyPrincipal(),
});
const fileSystem = new efs.FileSystem(this, 'MyEfsFileSystem', {
  vpc: new ec2.Vpc(this, 'VPC'),
  allowAnonymousAccess: true,
});

fileSystem.grantRead(role);
```

## Initializer

```ts
new FileSystem(scope: Construct, id: string, props: FileSystemProps)
```

## Construct Props

- `allowAnonymousAccess`: boolean — Allow access from anonymous client that doesn't use IAM authentication.

  **Default:** false when using `grantRead`, `grantWrite`, `grantRootAccess` or set `@aws-cdk/aws-efs:denyAnonymousAccess` feature flag, otherwise true

- `enableAutomaticBackups`: boolean = false — Whether to enable automatic backups for the file system.

- `encrypted`: boolean — Defines if the data at rest in the file system is encrypted or not.

  **Default:** If your application has the '@aws-cdk/aws-efs:defaultEncryptionAtRest' feature flag set, the default is true, otherwise, the default is false.

- `fileSystemName`: string — The file system's name.

  **Default:** CDK generated name

- `fileSystemPolicy`: [PolicyDocument](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.PolicyDocument.html) = none — File system policy is an IAM resource policy used to control NFS access to an EFS file system.

- `kmsKey`: [IKeyRef](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_kms.IKeyRef.html) — The KMS key used for encryption.

  **Default:** if 'encrypted' is true, the default key for EFS (/aws/elasticfilesystem) is used

  This is required to encrypt the data at rest if

- `lifecyclePolicy`: [LifecyclePolicy](/cdk/api/v2/docs/aws-cdk-lib.aws_efs.LifecyclePolicy.html) — A policy used by EFS lifecycle management to transition files to the Infrequent Access (IA) storage class.

  **Default:** None. EFS will not transition files to the IA storage class.

- `oneZone`: boolean = false — Whether this is a One Zone file system.

  If enabled, `performanceMode` must be set to `GENERAL_PURPOSE` and `vpcSubnets` cannot be set.

- `outOfInfrequentAccessPolicy`: [OutOfInfrequentAccessPolicy](/cdk/api/v2/docs/aws-cdk-lib.aws_efs.OutOfInfrequentAccessPolicy.html) — A policy used by EFS lifecycle management to transition files from Infrequent Access (IA) storage class to primary storage class.

  **Default:** None. EFS will not transition files from IA storage to primary storage.

- `performanceMode`: [PerformanceMode](/cdk/api/v2/docs/aws-cdk-lib.aws_efs.PerformanceMode.html) = PerformanceMode.GENERAL_PURPOSE — The performance mode that the file system will operate under.

  An Amazon EFS file system's performance mode can't be changed after the file system has been created.
  Updating this property will replace the file system.

- `provisionedThroughputPerSecond`: [Size](/cdk/api/v2/docs/aws-cdk-lib.Size.html) — Provisioned throughput for the file system.

  **Default:** none, errors out

  This is a required property if the throughput mode is set to PROVISIONED.
  Must be at least 1MiB/s.

- `removalPolicy`: [RemovalPolicy](/cdk/api/v2/docs/aws-cdk-lib.RemovalPolicy.html) = RemovalPolicy.RETAIN — The removal policy to apply to the file system.

- `replicationConfiguration`: [ReplicationConfiguration](/cdk/api/v2/docs/aws-cdk-lib.aws_efs.ReplicationConfiguration.html) — Replication configuration for the file system.

  **Default:** no replication

- `replicationOverwriteProtection`: [ReplicationOverwriteProtection](/cdk/api/v2/docs/aws-cdk-lib.aws_efs.ReplicationOverwriteProtection.html) — Whether to enable the filesystem's replication overwrite protection or not.

  **Default:** ReplicationOverwriteProtection.ENABLED

  Set false if you want to create a read-only filesystem for use as a replication destination.

- `securityGroup`: [ISecurityGroup](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.ISecurityGroup.html) — Security Group to assign to this file system.

  **Default:** creates new security group which allows all outbound traffic

- `throughputMode`: [ThroughputMode](/cdk/api/v2/docs/aws-cdk-lib.aws_efs.ThroughputMode.html) = ThroughputMode.BURSTING — Enum to mention the throughput mode of the file system.

- `transitionToArchivePolicy`: [LifecyclePolicy](/cdk/api/v2/docs/aws-cdk-lib.aws_efs.LifecyclePolicy.html) — The number of days after files were last accessed in primary storage (the Standard storage class) at which to move them to Archive storage.

  **Default:** None. EFS will not transition files to Archive storage class.

  Metadata operations such as listing the contents of a directory don't count as file access events.

- `vpc`: [IVpc](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html) (required) — VPC to launch the file system in.

- `vpcSubnets`: [SubnetSelection](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.SubnetSelection.html) — Which subnets to place the mount target in the VPC.

  **Default:** the Vpc default strategy if not specified

## Properties

- `connections`: [Connections](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Connections.html) — The security groups/rules used to allow network connections to the file system.

- `DEFAULT_PORT`: number (static) — The default port File System listens on.

- `env`: [ResourceEnvironment](/cdk/api/v2/docs/aws-cdk-lib.interfaces.ResourceEnvironment.html) — The environment this resource belongs to.

  For resources that are created and managed in a Stack (those created by
  creating new class instances like `new Role()`, `new Bucket()`, etc.), this
  is always the same as the environment of the stack they belong to.

  For referenced resources (those obtained from referencing methods like
  `Role.fromRoleArn()`, `Bucket.fromBucketName()`, etc.), they might be
  different than the stack they were imported into.

- `fileSystemArn`: string — The ARN of the file system.

- `fileSystemId`: string — The ID of the file system, assigned by Amazon EFS.

- `fileSystemRef`: [FileSystemReference](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_efs.FileSystemReference.html) — A reference to a FileSystem resource.

- `mountTargetsAvailable`: [IDependable](/cdk/api/v2/docs/constructs.IDependable.html) — Dependable that can be depended upon to ensure the mount targets of the filesystem are ready.

- `node`: [Node](/cdk/api/v2/docs/constructs.Node.html) — The tree node.

- `PROPERTY_INJECTION_ID`: string (static) — Uniquely identifies this class.

- `stack`: [Stack](/cdk/api/v2/docs/aws-cdk-lib.Stack.html) — The stack in which this resource is defined.

## Methods

- `addAccessPoint(id: string, accessPointOptions?: AccessPointOptions): AccessPoint` — create access point from this filesystem.

- `addToResourcePolicy(statement: PolicyStatement): AddToResourcePolicyResult` — Adds a statement to the resource policy associated with this file system.

  A resource policy will be automatically created upon the first call to `addToResourcePolicy`.

  Note that this does not work with imported file systems.

  **Parameters**

  - `statement` — The policy statement to add.

- `applyCrossStackReferenceStrength(strength: ReferenceStrength): void` — Override the cross-stack reference strength for this resource.

  When set, any cross-stack reference to this resource will use the specified
  mechanism instead of the global default determined by the
  `@aws-cdk/core:defaultCrossStackReferences` context key. This is useful for
  selectively weakening specific references to avoid the "deadly embrace" problem
  without changing the app-wide default.

  **Parameters**

  - `strength` — - The reference strength to use for this resource.

- `applyRemovalPolicy(policy: RemovalPolicy): void` — Apply the given removal policy to this resource.

  The Removal Policy controls what happens to this resource when it stops
  being managed by CloudFormation, either because you've removed it from the
  CDK application or because you've made a change that requires the resource
  to be replaced.

  The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS
  account for data recovery and cleanup later (`RemovalPolicy.RETAIN`).

- `fromFileSystemAttributes(scope: Construct, id: string, attrs: FileSystemAttributes): IFileSystem` (static) — Import an existing File System from the given properties.

- `grant(grantee: IGrantable, ...actions: string[]): Grant` — Grant the actions defined in actions to the given grantee on this File System resource.

  [disable-awslint:no-grants]

  **Parameters**

  - `grantee` — Principal to grant right to.
  - `actions` — The actions to grant.

- `grantRead(grantee: IGrantable): Grant` — Grant read permissions for this file system to an IAM principal.

  [disable-awslint:no-grants]

  **Parameters**

  - `grantee` — The principal to grant read to.

- `grantReadWrite(grantee: IGrantable): Grant` — Grant read and write permissions for this file system to an IAM principal.

  [disable-awslint:no-grants]

  **Parameters**

  - `grantee` — The principal to grant read and write to.

- `grantRootAccess(grantee: IGrantable): Grant` — As root user, grant read and write permissions for this file system to an IAM principal.

  [disable-awslint:no-grants]

  **Parameters**

  - `grantee` — The principal to grant root access to.

- `isConstruct(x: any): boolean` (static) — Checks if `x` is a construct.

  Use this method instead of `instanceof` to properly detect `Construct`
  instances, even when the construct library is symlinked.

  Explanation: in JavaScript, multiple copies of the `constructs` library on
  disk are seen as independent, completely different libraries. As a
  consequence, the class `Construct` in each copy of the `constructs` library
  is seen as a different class, and an instance of one class will not test as
  `instanceof` the other class. `npm install` will not create installations
  like this, but users may manually symlink construct libraries together or
  use a monorepo tool: in those cases, multiple copies of the `constructs`
  library can be accidentally installed, and `instanceof` will behave
  unpredictably. It is safest to avoid using `instanceof`, and using
  this type-testing method instead.

  **Parameters**

  - `x` — Any object.

  **Returns:** true if `x` is an object created from a class which extends `Construct`.

- `isOwnedResource(construct: IConstruct): boolean` (static) — Returns true if the construct was created by CDK, and false otherwise.

- `isResource(construct: IConstruct): boolean` (static) — Check whether the given construct is a Resource.

- `toString(): string` — Returns a string representation of this construct.

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  Mixins are applied in order. The list of constructs is captured at the
  start of the call, so constructs added by a mixin will not be visited.
  Use multiple `with()` calls if subsequent mixins should apply to added
  constructs.
