Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
@aws-cdk/aws-efs
Advanced tools
@aws-cdk/aws-efs is an AWS CDK library that allows you to define and manage Amazon Elastic File System (EFS) resources in your AWS infrastructure as code. It provides constructs for creating and configuring EFS file systems, access points, and mount targets.
Create an EFS File System
This code sample demonstrates how to create an EFS file system with specific lifecycle policies, performance mode, and throughput mode.
const efs = require('@aws-cdk/aws-efs');
const cdk = require('@aws-cdk/core');
const app = new cdk.App();
const stack = new cdk.Stack(app, 'EfsStack');
const fileSystem = new efs.FileSystem(stack, 'MyEfsFileSystem', {
vpc: vpc,
lifecyclePolicy: efs.LifecyclePolicy.AFTER_14_DAYS,
performanceMode: efs.PerformanceMode.GENERAL_PURPOSE,
throughputMode: efs.ThroughputMode.BURSTING,
});
app.synth();
Create an EFS Access Point
This code sample demonstrates how to create an EFS access point with specific POSIX user and ACL settings.
const efs = require('@aws-cdk/aws-efs');
const cdk = require('@aws-cdk/core');
const app = new cdk.App();
const stack = new cdk.Stack(app, 'EfsStack');
const fileSystem = new efs.FileSystem(stack, 'MyEfsFileSystem', {
vpc: vpc,
});
const accessPoint = new efs.AccessPoint(stack, 'MyAccessPoint', {
fileSystem: fileSystem,
path: '/export/lambda',
posixUser: {
uid: '1001',
gid: '1001'
},
createAcl: {
ownerUid: '1001',
ownerGid: '1001',
permissions: '755'
},
});
app.synth();
Create an EFS Mount Target
This code sample demonstrates how to create an EFS mount target in a specific subnet with a security group.
const efs = require('@aws-cdk/aws-efs');
const cdk = require('@aws-cdk/core');
const app = new cdk.App();
const stack = new cdk.Stack(app, 'EfsStack');
const fileSystem = new efs.FileSystem(stack, 'MyEfsFileSystem', {
vpc: vpc,
});
const mountTarget = new efs.CfnMountTarget(stack, 'MyMountTarget', {
fileSystemId: fileSystem.fileSystemId,
subnetId: vpc.privateSubnets[0].subnetId,
securityGroups: [securityGroup.securityGroupId],
});
app.synth();
@aws-cdk/aws-s3 is a CDK library for defining Amazon S3 buckets and related resources. While it focuses on object storage rather than file storage, it provides similar infrastructure-as-code capabilities for managing storage resources in AWS.
@aws-cdk/aws-ec2 is a CDK library for defining Amazon EC2 instances, VPCs, and related networking resources. It can be used in conjunction with @aws-cdk/aws-efs to set up the necessary networking infrastructure for EFS file systems.
@aws-cdk/aws-rds is a CDK library for defining Amazon RDS databases and related resources. While it focuses on relational databases rather than file storage, it provides similar infrastructure-as-code capabilities for managing database resources in AWS.
All classes with the
Cfn
prefix in this module (CFN Resources) are always stable and safe to use.
The APIs of higher level constructs in this module are experimental and under active development. They are subject to non-backward compatible changes or removal in any future version. These are not subject to the Semantic Versioning model and breaking changes will be announced in the release notes. This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.
This construct library allows you to set up AWS Elastic File System (EFS).
import * as efs from '@aws-cdk/aws-efs';
const myVpc = new ec2.Vpc(this, 'VPC');
const fileSystem = new efs.FileSystem(this, 'MyEfsFileSystem', {
vpc: myVpc,
encrypted: true,
lifecyclePolicy: efs.LifecyclePolicy.AFTER_14_DAYS,
performanceMode: efs.PerformanceMode.GENERAL_PURPOSE,
throughputMode: efs.ThroughputMode.BURSTING
});
A file system can set RemovalPolicy
. Default policy is RETAIN
.
const fileSystem = new FileSystem(this, 'EfsFileSystem', {
vpc,
removalPolicy: RemovalPolicy.DESTROY
});
An access point is an application-specific view into an EFS file system that applies an operating system user and group, and a file system path, to any file system request made through the access point. The operating system user and group override any identity information provided by the NFS client. The file system path is exposed as the access point's root directory. Applications using the access point can only access data in its own directory and below. To learn more, see Mounting a File System Using EFS Access Points.
Use addAccessPoint
to create an access point from a fileSystem:
fileSystem.addAccessPoint('AccessPoint');
By default, when you create an access point, the root(/
) directory is exposed to the client connecting to
the access point. You may specify custom path with the path
property. If path
does not exist, it will be
created with the settings defined in the creationInfo
. See
Creating Access Points for more details.
To control who can access the EFS, use the .connections
attribute. EFS has
a fixed default port, so you don't need to specify the port:
fileSystem.connections.allowDefaultPortFrom(instance);
In order to automatically mount this file system during instance launch, following code can be used as reference:
const vpc = new ec2.Vpc(this, 'VPC');
const fileSystem = new efs.FileSystem(this, 'MyEfsFileSystem', {
vpc,
encrypted: true,
lifecyclePolicy: efs.LifecyclePolicy.AFTER_14_DAYS,
performanceMode: efs.PerformanceMode.GENERAL_PURPOSE,
throughputMode: efs.ThroughputMode.BURSTING,
enableAutomaticBackups: true
});
const inst = new Instance(this, 'inst', {
instanceType: InstanceType.of(InstanceClass.T2, InstanceSize.LARGE),
machineImage: new AmazonLinuxImage({
generation: AmazonLinuxGeneration.AMAZON_LINUX_2
}),
vpc,
vpcSubnets: {
subnetType: SubnetType.PUBLIC,
}
});
fileSystem.connections.allowDefaultPortFrom(inst);
inst.userData.addCommands("yum check-update -y", // Ubuntu: apt-get -y update
"yum upgrade -y", // Ubuntu: apt-get -y upgrade
"yum install -y amazon-efs-utils", // Ubuntu: apt-get -y install amazon-efs-utils
"yum install -y nfs-utils", // Ubuntu: apt-get -y install nfs-common
"file_system_id_1=" + fileSystem.fileSystemId,
"efs_mount_point_1=/mnt/efs/fs1",
"mkdir -p \"${efs_mount_point_1}\"",
"test -f \"/sbin/mount.efs\" && echo \"${file_system_id_1}:/ ${efs_mount_point_1} efs defaults,_netdev\" >> /etc/fstab || " +
"echo \"${file_system_id_1}.efs." + cdk.Stack.of(this).region + ".amazonaws.com:/ ${efs_mount_point_1} nfs4 nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport,_netdev 0 0\" >> /etc/fstab",
"mount -a -t efs,nfs4 defaults");
This module is part of the AWS Cloud Development Kit project.
1.72.0 (2020-11-06)
enableHttpEndpoint
renamed to enableDataApi
outputLocation
in the experimental Athena StartQueryExecution
has been changed to s3.Location
from string
Environment
from attributes (#10932) (d395b5e), closes #10931--no-previous-parameters
incorrectly skips updates (#11288) (1bfc649)FAQs
The CDK Construct Library for AWS::EFS
The npm package @aws-cdk/aws-efs receives a total of 188,014 weekly downloads. As such, @aws-cdk/aws-efs popularity was classified as popular.
We found that @aws-cdk/aws-efs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.