Skip to main content

The CDK Construct Library for AWS::EFS

Project description

Amazon Elastic File System Construct Library

---

Stability: Experimental

This is a developer preview (public beta) module.

All classes with the Cfn prefix in this module (CFN Resources) are auto-generated from CloudFormation. They are stable and safe to use.

However, all other classes, i.e., higher level constructs, are under active development and subject to non-backward compatible changes or removal in any future version. These are not subject to the Semantic Versioning model. 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).

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
import aws_cdk.aws_efs as efs

my_vpc = ec2.Vpc(self, "VPC")
file_system = efs.EfsFileSystem(self, "MyEfsFileSystem",
    vpc=my_vpc,
    encrypted=True,
    lifecycle_policy=EfsLifecyclePolicyProperty.AFTER_14_DAYS,
    performance_mode=EfsPerformanceMode.GENERAL_PURPOSE,
    throughput_mode=EfsThroughputMode.BURSTING
)

Connecting

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:

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
file_system.connections.allow_default_port_from(instance)

Mounting the file system using User Data

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.EfsFileSystem(this, 'EfsFileSystem', {
  vpc,
  encrypted: true,
  lifecyclePolicy: efs.EfsLifecyclePolicyProperty.AFTER_14_DAYS,
  performanceMode: efs.EfsPerformanceMode.GENERAL_PURPOSE,
  throughputMode: efs.EfsThroughputMode.BURSTING
});

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.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aws-cdk.aws-efs-1.29.0.tar.gz (50.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aws_cdk.aws_efs-1.29.0-py3-none-any.whl (48.5 kB view details)

Uploaded Python 3

File details

Details for the file aws-cdk.aws-efs-1.29.0.tar.gz.

File metadata

  • Download URL: aws-cdk.aws-efs-1.29.0.tar.gz
  • Upload date:
  • Size: 50.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.5

File hashes

Hashes for aws-cdk.aws-efs-1.29.0.tar.gz
Algorithm Hash digest
SHA256 e3c41aa62d44cbb037a066d9153bce4f95dc4daadad8cc5b213e4c7b23395bde
MD5 ec8c0a6a0291102441d3ea869dd4961b
BLAKE2b-256 771006b97ff66273ebbb4c9137f481b90fe6f7639ead27900ef902c871bebbb9

See more details on using hashes here.

File details

Details for the file aws_cdk.aws_efs-1.29.0-py3-none-any.whl.

File metadata

  • Download URL: aws_cdk.aws_efs-1.29.0-py3-none-any.whl
  • Upload date:
  • Size: 48.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.5

File hashes

Hashes for aws_cdk.aws_efs-1.29.0-py3-none-any.whl
Algorithm Hash digest
SHA256 41d1758138ff7b848d8a6586eab3208d6bd18a1d39aaf534466aa31dad17ad00
MD5 7c26875c236ef110ade8534c57cf3598
BLAKE2b-256 5d85efa102a2e847b319d41f069ff73a802274b3eb37faa289d5fab7d1a998a6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page