Socket
Socket
Sign inDemoInstall

@aws-cdk/aws-efs

Package Overview
Dependencies
26
Maintainers
5
Versions
288
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @aws-cdk/aws-efs

The CDK Construct Library for AWS::EFS


Version published
Weekly downloads
115K
decreased by-0.68%
Maintainers
5
Created
Weekly downloads
 

Changelog

Source

1.72.0 (2020-11-06)

⚠ BREAKING CHANGES TO EXPERIMENTAL FEATURES

  • rds: Serverless cluster enableHttpEndpoint renamed to enableDataApi
  • stepfunctions-tasks: type of outputLocation in the experimental Athena StartQueryExecution has been changed to s3.Location from string

Features

Bug Fixes

  • apigateway: changes to gateway response does not trigger auto deployment (#11068) (0c8264a), closes #10963
  • cfnspec: incorrect Route 53 health check configuration properties in CloudFormation specification (#11280) (f3c8b50), closes #issuecomment-717435271 #11096
  • cli: --no-previous-parameters incorrectly skips updates (#11288) (1bfc649)
  • core: many nested stacks make NodeJS run out of memory (#11250) (c124886)
  • core: multiple library copies lead to 'Assets must be defined within Stage or App' error (#11113) (fcfed39), closes #10314
  • core: support docker engine v20.10.0-beta1 (#11124) (87887a3)
  • dynamodb: Misconfigured metrics causing empty graphs (#11283) (9968669)
  • ecs: redirect config should honor openListener flag (#11115) (ed6e7ed)
  • event-targets: circular dependency when the lambda target is in a different stack (#11217) (e21f249), closes #10942
  • pipelines: asset stage can't support more than 50 assets (#11284) (5db8e80), closes #9353
  • secretsmanager: can't export secret name from Secret (#11202) (5dcdecb), closes #10914
  • secretsmanager: Secret.fromSecretName doesn't work with ECS (#11042) (fe1ce73), closes #10309 #10519
  • stepfunctions: stack overflow when referenced json path finding encounters a circular object graph (#11225) (f14d823), closes #9319
  • stepfunctions-tasks: Athena* APIs have incorrect supported integration patterns (#11188) (0f66833), closes #11045 #11246
  • stepfunctions-tasks: incorrect S3 permissions for AthenaStartQueryExecution (#11203) (b35c423)
  • explicitly set the 'ImagePullPrincipalType' of image (#11264) (29aa223), closes #10569

Readme

Source

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

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
});

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:

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.

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:

fileSystem.connections.allowDefaultPortFrom(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.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.

Keywords

FAQs

Last updated on 06 Nov 2020

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc