Skip to content
v2.274.0

EfsVolume Class ​

A Volume that uses an AWS Elastic File System (EFS);

this volume can grow and shrink as needed

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_batch as batch } from 'aws-cdk-lib';
import { aws_efs as interfaces_efs } from 'aws-cdk-lib/interfaces';

declare const fileSystemRef: interfaces_efs.IFileSystemRef;
const efsVolume = new batch.EfsVolume({
  containerPath: 'containerPath',
  fileSystem: fileSystemRef,
  name: 'name',

  // the properties below are optional
  accessPointId: 'accessPointId',
  enableTransitEncryption: false,
  readonly: false,
  rootDirectory: 'rootDirectory',
  transitEncryptionPort: 123,
  useJobRole: false,
});
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_batch as batch
from aws_cdk.interfaces import aws_efs as interfaces_efs

# file_system_ref: interfaces_efs.IFileSystemRef

efs_volume = batch.EfsVolume(
    container_path="containerPath",
    file_system=file_system_ref,
    name="name",

    # the properties below are optional
    access_point_id="accessPointId",
    enable_transit_encryption=False,
    readonly=False,
    root_directory="rootDirectory",
    transit_encryption_port=123,
    use_job_role=False
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.batch.*;
import software.amazon.awscdk.interfaces.efs.*;

IFileSystemRef fileSystemRef;

EfsVolume efsVolume = EfsVolume.Builder.create()
        .containerPath("containerPath")
        .fileSystem(fileSystemRef)
        .name("name")

        // the properties below are optional
        .accessPointId("accessPointId")
        .enableTransitEncryption(false)
        .readonly(false)
        .rootDirectory("rootDirectory")
        .transitEncryptionPort(123)
        .useJobRole(false)
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.Batch;
using Amazon.CDK.Interfaces.EFS;

IFileSystemRef fileSystemRef;

var efsVolume = new EfsVolume(new EfsVolumeOptions {
    ContainerPath = "containerPath",
    FileSystem = fileSystemRef,
    Name = "name",

    // the properties below are optional
    AccessPointId = "accessPointId",
    EnableTransitEncryption = false,
    Readonly = false,
    RootDirectory = "rootDirectory",
    TransitEncryptionPort = 123,
    UseJobRole = false
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var fileSystemRef IFileSystemRef

efsVolume := awscdk.Aws_batch.NewEfsVolume(&EfsVolumeOptions{
	ContainerPath: jsii.String("containerPath"),
	FileSystem: fileSystemRef,
	Name: jsii.String("name"),

	// the properties below are optional
	AccessPointId: jsii.String("accessPointId"),
	EnableTransitEncryption: jsii.Boolean(false),
	Readonly: jsii.Boolean(false),
	RootDirectory: jsii.String("rootDirectory"),
	TransitEncryptionPort: jsii.Number(123),
	UseJobRole: jsii.Boolean(false),
})

Initializer ​

ts
new EfsVolume(options: EfsVolumeOptions)
python
EfsVolume(options: EfsVolumeOptions)
java
new EfsVolume(EfsVolumeOptions options)
csharp
new EfsVolume(EfsVolumeOptions options)
go
NewEfsVolume(Options EfsVolumeOptions)

Properties ​

accessPointIdstringaccess_point_idstraccessPointIdStringAccessPointIdstringAccessPointId*string= no accessPointId#
The Amazon EFS access point ID to use.

If an access point is specified, rootDirectory must either be omitted or set to / which enforces the path set on the EFS access point. If an access point is used, enableTransitEncryption must be true.

containerPathstringcontainer_pathstrcontainerPathStringContainerPathstringContainerPath*stringrequired#
The path on the container that this volume will be mounted to.
enableTransitEncryptionbooleanenable_transit_encryptionboolenableTransitEncryptionBooleanEnableTransitEncryptionboolEnableTransitEncryption*bool= false#
Enables encryption for Amazon EFS data in transit between the Amazon ECS host and the Amazon EFS server.
fileSystemIFileSystemfile_systemIFileSystemfileSystemIFileSystemFileSystemIFileSystemFileSystemIFileSystemrequired#
The EFS File System that supports this volume.
namestringnamestrnameStringNamestringName*stringrequired#
The name of this volume.
readonlybooleanreadonlyboolreadonlyBooleanReadonlyboolReadonly*bool= false#
Whether or not the container has readonly access to this volume.
rootDirectorystringroot_directorystrrootDirectoryStringRootDirectorystringRootDirectory*string= root of the EFS File System#
The directory within the Amazon EFS file system to mount as the root directory inside the host.

If this parameter is omitted, the root of the Amazon EFS volume is used instead. Specifying / has the same effect as omitting this parameter. The maximum length is 4,096 characters.

transitEncryptionPortnumbertransit_encryption_portint | floattransitEncryptionPortNumberTransitEncryptionPortdoubleTransitEncryptionPort*float64= chosen by the EFS Mount Helper#
The port to use when sending encrypted data between the Amazon ECS host and the Amazon EFS server.

The value must be between 0 and 65,535.

useJobRolebooleanuse_job_rolebooluseJobRoleBooleanUseJobRoleboolUseJobRole*bool= false#
Whether or not to use the AWS Batch job IAM role defined in a job definition when mounting the Amazon EFS file system.

If specified, enableTransitEncryption must be true.

Methods ​

efs(options: EfsVolumeOptions): EfsVolume // chainable@staticmethod def efs(options: EfsVolumeOptions) -> EfsVolumepublic static EfsVolume efs(EfsVolumeOptions options)public static EfsVolume Efs(EfsVolumeOptions options)func Efs(Options EfsVolumeOptions) EfsVolumestatic#
Creates a Volume that uses an AWS Elastic File System (EFS);

this volume can grow and shrink as needed

host(options: HostVolumeOptions): HostVolume@staticmethod def host(options: HostVolumeOptions) -> HostVolumepublic static HostVolume host(HostVolumeOptions options)public static HostVolume Host(HostVolumeOptions options)func Host(Options HostVolumeOptions) HostVolumestatic#
Creates a Host volume.

This volume will persist on the host at the specified hostPath. If the hostPath is not specified, Docker will choose the host path. In this case, the data may not persist after the containers that use it stop running.

isEfsVolume(x: any): boolean@staticmethod def is_efs_volume(x: Any) -> boolpublic static Boolean isEfsVolume(Object x)public static bool IsEfsVolume(object x)func IsEfsVolume(X interface{}) *boolstatic#
Returns true if x is an EfsVolume, false otherwise.