class FileSystem (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.EFS.FileSystem |
Java | software.amazon.awscdk.services.efs.FileSystem |
Python | aws_cdk.aws_efs.FileSystem |
TypeScript (source) | @aws-cdk/aws-efs » FileSystem |
Implements
IConstruct
, IConstruct
, IDependable
, IResource
, IFile
, IConnectable
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
File
System Props
Constructor for creating a new EFS FileSystem.
Construct Props
Name | Type | Description |
---|---|---|
vpc | IVpc | VPC to launch the file system in. |
enable | boolean | 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. |
file | string | The file system's name. |
kms | IKey | The KMS key used for encryption. |
lifecycle | Lifecycle | A policy used by EFS lifecycle management to transition files to the Infrequent Access (IA) storage class. |
out | Out | A policy used by EFS lifecycle management to transition files from Infrequent Access (IA) storage class to primary storage class. |
performance | Performance | The performance mode that the file system will operate under. |
provisioned | Size | Provisioned throughput for the file system. |
removal | Removal | The removal policy to apply to the file system. |
security | ISecurity | Security Group to assign to this file system. |
throughput | Throughput | Enum to mention the throughput mode of the file system. |
vpc | Subnet | Which 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 ')
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.
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:
Lifecycle
(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:
Out
(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:
Performance
(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:
Removal
(optional, default: RemovalPolicy.RETAIN)
The removal policy to apply to the file system.
securityGroup?
Type:
ISecurity
(optional, default: creates new security group which allows all outbound traffic)
Security Group to assign to this file system.
throughputMode?
Type:
Throughput
(optional, default: ThroughputMode.BURSTING)
Enum to mention the throughput mode of the file system.
vpcSubnets?
Type:
Subnet
(optional, default: the Vpc default strategy if not specified)
Which subnets to place the mount target in the VPC.
Properties
Name | Type | Description |
---|---|---|
connections | Connections | The security groups/rules used to allow network connections to the file system. |
env | Resource | The environment this resource belongs to. |
file | string | The ARN of the file system. |
file | string | The ID of the file system, assigned by Amazon EFS. |
mount | IDependable | Dependable that can be depended upon to ensure the mount targets of the filesystem are ready. |
node | Construct | The construct tree node associated with this construct. |
stack | Stack | The stack in which this resource is defined. |
static DEFAULT_PORT | number | The default port File System listens on. |
connections
Type:
Connections
The security groups/rules used to allow network connections to the file system.
env
Type:
Resource
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:
Construct
The construct tree node associated with this construct.
stack
Type:
Stack
The stack in which this resource is defined.
static DEFAULT_PORT
Type:
number
The default port File System listens on.
Methods
Name | Description |
---|---|
add | create access point from this filesystem. |
apply | 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. |
to | Returns a string representation of this construct. |
static from | Import an existing File System from the given properties. |
AccessPoint(id, accessPointOptions?)
addpublic addAccessPoint(id: string, accessPointOptions?: AccessPointOptions): AccessPoint
Parameters
- id
string
- accessPointOptions
Access
Point Options
Returns
create access point from this filesystem.
RemovalPolicy(policy)
applypublic applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
Policy
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 the actions defined in actions to the given grantee on this File System resource.
String()
topublic toString(): string
Returns
string
Returns a string representation of this construct.
FileSystemAttributes(scope, id, attrs)
static frompublic static fromFileSystemAttributes(scope: Construct, id: string, attrs: FileSystemAttributes): IFileSystem
Parameters
- scope
Construct
- id
string
- attrs
File
System Attributes
Returns
Import an existing File System from the given properties.