Skip to main content

The CDK Construct Library for AWS::EFS

Project description

Amazon Elastic File System Construct Library

---

cfn-resources: Stable

All classes with the Cfn prefix in this module (CFN Resources) are always stable and safe to use.

cdk-constructs: Experimental

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

# 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.FileSystem(self, "MyEfsFileSystem",
    vpc=my_vpc,
    encrypted=True,
    lifecycle_policy=efs.LifecyclePolicy.AFTER_14_DAYS,
    performance_mode=efs.PerformanceMode.GENERAL_PURPOSE,
    throughput_mode=efs.ThroughputMode.BURSTING
)

A file system can set RemovalPolicy. Default policy is RETAIN.

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
file_system = FileSystem(self, "EfsFileSystem",
    vpc=vpc,
    removal_policy=RemovalPolicy.DESTROY
)

Access Point

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:

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
file_system.add_access_point("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.

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:

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
vpc = ec2.Vpc(self, "VPC")

file_system = efs.FileSystem(self, "MyEfsFileSystem",
    vpc=vpc,
    encrypted=True,
    lifecycle_policy=efs.LifecyclePolicy.AFTER_14_DAYS,
    performance_mode=efs.PerformanceMode.GENERAL_PURPOSE,
    throughput_mode=efs.ThroughputMode.BURSTING
)

inst = Instance(self, "inst",
    instance_type=InstanceType.of(InstanceClass.T2, InstanceSize.LARGE),
    machine_image=AmazonLinuxImage(
        generation=AmazonLinuxGeneration.AMAZON_LINUX_2
    ),
    vpc=vpc,
    vpc_subnets={
        "subnet_type": SubnetType.PUBLIC
    }
)

file_system.connections.allow_default_port_from(inst)

inst.user_data.add_commands("yum check-update -y", "yum upgrade -y", "yum install -y amazon-efs-utils", "yum install -y nfs-utils", "file_system_id_1=" + file_system.file_system_id, "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(self).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.61.0.tar.gz (78.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.61.0-py3-none-any.whl (76.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aws-cdk.aws-efs-1.61.0.tar.gz
  • Upload date:
  • Size: 78.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.5

File hashes

Hashes for aws-cdk.aws-efs-1.61.0.tar.gz
Algorithm Hash digest
SHA256 1ca42a7976bf55a6d6d36cc9f48b039b898fdd3bbdd55408460694ac25eb93d3
MD5 59c20ff94a8909bb4610abebe749ef99
BLAKE2b-256 91c1edcc8ae0bc2fbf19ddf33e5471907d1fde7695557fee5390c6d02f7c7df2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aws_cdk.aws_efs-1.61.0-py3-none-any.whl
  • Upload date:
  • Size: 76.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.5

File hashes

Hashes for aws_cdk.aws_efs-1.61.0-py3-none-any.whl
Algorithm Hash digest
SHA256 73f56553983e84d320abb00230637655a01bad4617f41d93122a7f1532b0b1c9
MD5 555490a7b25e2d2c51530e47599eec1c
BLAKE2b-256 a4015d894d004ad3bb3b7ddc372715847b9409ca87f3de80b913849bb85bcb74

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