aws-cdk-lib.aws_efs.FileSystem

class FileSystem (construct)

LanguageType name
.NETAmazon.CDK.AWS.EFS.FileSystem
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsefs#FileSystem
Javasoftware.amazon.awscdk.services.efs.FileSystem
Pythonaws_cdk.aws_efs.FileSystem
TypeScript (source)aws-cdk-lib » aws_efs » FileSystem

Implements IConstruct, IDependable, IResource, IFileSystem, IConnectable, IResourceWithPolicy

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.

See also: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-efs-filesystem.html

Example

const fileSystem = new efs.FileSystem(this, 'MyEfsFileSystem', {
  vpc: new ec2.Vpc(this, 'VPC'),
  lifecyclePolicy: efs.LifecyclePolicy.AFTER_14_DAYS, // files are not transitioned to infrequent access (IA) storage by default
  performanceMode: efs.PerformanceMode.GENERAL_PURPOSE, // default
  outOfInfrequentAccessPolicy: efs.OutOfInfrequentAccessPolicy.AFTER_1_ACCESS, // files are not transitioned back from (infrequent access) IA to primary storage by default
});

Initializer

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

Parameters

  • scope Construct
  • id string
  • props FileSystemProps

Constructor for creating a new EFS FileSystem.

Construct Props

NameTypeDescription
vpcIVpcVPC to launch the file system in.
enableAutomaticBackups?booleanWhether to enable automatic backups for the file system.
encrypted?booleanDefines if the data at rest in the file system is encrypted or not.
fileSystemName?stringThe file system's name.
fileSystemPolicy?PolicyDocumentFile system policy is an IAM resource policy used to control NFS access to an EFS file system.
kmsKey?IKeyThe KMS key used for encryption.
lifecyclePolicy?LifecyclePolicyA policy used by EFS lifecycle management to transition files to the Infrequent Access (IA) storage class.
outOfInfrequentAccessPolicy?OutOfInfrequentAccessPolicyA policy used by EFS lifecycle management to transition files from Infrequent Access (IA) storage class to primary storage class.
performanceMode?PerformanceModeThe performance mode that the file system will operate under.
provisionedThroughputPerSecond?SizeProvisioned throughput for the file system.
removalPolicy?RemovalPolicyThe removal policy to apply to the file system.
securityGroup?ISecurityGroupSecurity Group to assign to this file system.
throughputMode?ThroughputModeEnum to mention the throughput mode of the file system.
vpcSubnets?SubnetSelectionWhich subnets to place the mount target in the VPC.

vpc

Type: IVpc

VPC to launch the file system in.


enableAutomaticBackups?

Type: boolean (optional, default: false)

Whether to enable automatic backups for the file system.


encrypted?

Type: boolean (optional, default: If your application has the '@aws-cdk/aws-efs:defaultEncryptionAtRest' feature flag set, the default is true, otherwise, the default is false.)

Defines if the data at rest in the file system is encrypted or not.


fileSystemName?

Type: string (optional, default: CDK generated name)

The file system's name.


fileSystemPolicy?

Type: PolicyDocument (optional, default: none)

File system policy is an IAM resource policy used to control NFS access to an EFS file system.


kmsKey?

Type: IKey (optional, default: if 'encrypted' is true, the default key for EFS (/aws/elasticfilesystem) is used)

The KMS key used for encryption.

This is required to encrypt the data at rest if @encrypted is set to true.


lifecyclePolicy?

Type: LifecyclePolicy (optional, default: None. EFS will not transition files to the IA storage class.)

A policy used by EFS lifecycle management to transition files to the Infrequent Access (IA) storage class.


outOfInfrequentAccessPolicy?

Type: OutOfInfrequentAccessPolicy (optional, default: None. EFS will not transition files from IA storage to primary storage.)

A policy used by EFS lifecycle management to transition files from Infrequent Access (IA) storage class to primary storage class.


performanceMode?

Type: PerformanceMode (optional, default: 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?

Type: Size (optional, default: none, errors out)

Provisioned throughput for the file system.

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


removalPolicy?

Type: RemovalPolicy (optional, default: RemovalPolicy.RETAIN)

The removal policy to apply to the file system.


securityGroup?

Type: ISecurityGroup (optional, default: creates new security group which allows all outbound traffic)

Security Group to assign to this file system.


throughputMode?

Type: ThroughputMode (optional, default: ThroughputMode.BURSTING)

Enum to mention the throughput mode of the file system.


vpcSubnets?

Type: SubnetSelection (optional, default: the Vpc default strategy if not specified)

Which subnets to place the mount target in the VPC.

Properties

NameTypeDescription
connectionsConnectionsThe security groups/rules used to allow network connections to the file system.
envResourceEnvironmentThe environment this resource belongs to.
fileSystemArnstringThe ARN of the file system.
fileSystemIdstringThe ID of the file system, assigned by Amazon EFS.
mountTargetsAvailableIDependableDependable that can be depended upon to ensure the mount targets of the filesystem are ready.
nodeNodeThe tree node.
stackStackThe stack in which this resource is defined.
static DEFAULT_PORTnumberThe default port File System listens on.

connections

Type: Connections

The security groups/rules used to allow network connections to the file system.


env

Type: ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.


fileSystemArn

Type: string

The ARN of the file system.


fileSystemId

Type: string

The ID of the file system, assigned by Amazon EFS.


mountTargetsAvailable

Type: IDependable

Dependable that can be depended upon to ensure the mount targets of the filesystem are ready.


node

Type: Node

The tree node.


stack

Type: Stack

The stack in which this resource is defined.


static DEFAULT_PORT

Type: number

The default port File System listens on.

Methods

NameDescription
addAccessPoint(id, accessPointOptions?)create access point from this filesystem.
addToResourcePolicy(statement)Adds a statement to the resource policy associated with this file system.
applyRemovalPolicy(policy)Apply the given removal policy to this resource.
grant(grantee, ...actions)Grant the actions defined in actions to the given grantee on this File System resource.
toString()Returns a string representation of this construct.
static fromFileSystemAttributes(scope, id, attrs)Import an existing File System from the given properties.

addAccessPoint(id, accessPointOptions?)

public addAccessPoint(id: string, accessPointOptions?: AccessPointOptions): AccessPoint

Parameters

  • id string
  • accessPointOptions AccessPointOptions

Returns

  • AccessPoint

create access point from this filesystem.


addToResourcePolicy(statement)

public addToResourcePolicy(statement: PolicyStatement): AddToResourcePolicyResult

Parameters

  • statement PolicyStatement — The policy statement to add.

Returns

  • 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.


applyRemovalPolicy(policy)

public applyRemovalPolicy(policy: RemovalPolicy): void

Parameters

  • policy RemovalPolicy

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).


grant(grantee, ...actions)

public grant(grantee: IGrantable, ...actions: string[]): Grant

Parameters

  • grantee IGrantable — Principal to grant right to.
  • actions string — The actions to grant.

Returns

  • Grant

Grant the actions defined in actions to the given grantee on this File System resource.


toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.


static fromFileSystemAttributes(scope, id, attrs)

public static fromFileSystemAttributes(scope: Construct, id: string, attrs: FileSystemAttributes): IFileSystem

Parameters

  • scope Construct
  • id string
  • attrs FileSystemAttributes

Returns

  • IFileSystem

Import an existing File System from the given properties.