EfsVolumeOptions Struct
Options for configuring an EfsVolume.
Example
ts
declare const myFileSystem: efs.IFileSystem;
declare const myJobRole: iam.Role;
myFileSystem.grantRead(myJobRole);
const jobDefn = new batch.EcsJobDefinition(this, 'JobDefn', {
container: new batch.EcsEc2ContainerDefinition(this, 'containerDefn', {
image: ecs.ContainerImage.fromRegistry('public.ecr.aws/amazonlinux/amazonlinux:latest'),
memory: cdk.Size.mebibytes(2048),
cpu: 256,
volumes: [batch.EcsVolume.efs({
name: 'myVolume',
fileSystem: myFileSystem,
containerPath: '/Volumes/myVolume',
useJobRole: true,
})],
jobRole: myJobRole,
}),
});
python
# my_file_system: efs.IFileSystem
# my_job_role: iam.Role
my_file_system.grant_read(my_job_role)
job_defn = batch.EcsJobDefinition(self, "JobDefn",
container=batch.EcsEc2ContainerDefinition(self, "containerDefn",
image=ecs.ContainerImage.from_registry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
memory=cdk.Size.mebibytes(2048),
cpu=256,
volumes=[batch.EcsVolume.efs(
name="myVolume",
file_system=my_file_system,
container_path="/Volumes/myVolume",
use_job_role=True
)],
job_role=my_job_role
)
)
java
IFileSystem myFileSystem;
Role myJobRole;
myFileSystem.grantRead(myJobRole);
EcsJobDefinition jobDefn = EcsJobDefinition.Builder.create(this, "JobDefn")
.container(EcsEc2ContainerDefinition.Builder.create(this, "containerDefn")
.image(ContainerImage.fromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"))
.memory(Size.mebibytes(2048))
.cpu(256)
.volumes(List.of(EcsVolume.efs(EfsVolumeOptions.builder()
.name("myVolume")
.fileSystem(myFileSystem)
.containerPath("/Volumes/myVolume")
.useJobRole(true)
.build())))
.jobRole(myJobRole)
.build())
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
IFileSystem myFileSystem;
Role myJobRole;
myFileSystem.GrantRead(myJobRole);
var jobDefn = new EcsJobDefinition(this, "JobDefn", new EcsJobDefinitionProps {
Container = new EcsEc2ContainerDefinition(this, "containerDefn", new EcsEc2ContainerDefinitionProps {
Image = ContainerImage.FromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
Memory = Size.Mebibytes(2048),
Cpu = 256,
Volumes = new [] { EcsVolume.Efs(new EfsVolumeOptions {
Name = "myVolume",
FileSystem = myFileSystem,
ContainerPath = "/Volumes/myVolume",
UseJobRole = true
}) },
JobRole = myJobRole
})
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var myFileSystem IFileSystem
var myJobRole Role
myFileSystem.GrantRead(myJobRole)
jobDefn := batch.NewEcsJobDefinition(this, jsii.String("JobDefn"), &EcsJobDefinitionProps{
Container: batch.NewEcsEc2ContainerDefinition(this, jsii.String("containerDefn"), &EcsEc2ContainerDefinitionProps{
Image: ecs.ContainerImage_FromRegistry(jsii.String("public.ecr.aws/amazonlinux/amazonlinux:latest")),
Memory: cdk.Size_Mebibytes(jsii.Number(2048)),
Cpu: jsii.Number(256),
Volumes: []EcsVolume{
batch.EcsVolume_Efs(&EfsVolumeOptions{
Name: jsii.String("myVolume"),
FileSystem: myFileSystem,
ContainerPath: jsii.String("/Volumes/myVolume"),
UseJobRole: jsii.Boolean(true),
}),
},
JobRole: myJobRole,
}),
})
Properties
accessPointIdoptionalstringaccess_point_idoptionalstraccessPointIdoptionalStringAccessPointIdoptionalstringAccessPointIdoptional*string#The Amazon EFS access point ID to use.
Default: no accessPointId
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 where this volume is mounted.
enableTransitEncryptionoptionalbooleanenable_transit_encryptionoptionalboolenableTransitEncryptionoptionalBooleanEnableTransitEncryptionoptionalboolEnableTransitEncryptionoptional*bool= false#Enables encryption for Amazon EFS data in transit between the Amazon ECS host and the Amazon EFS server.
fileSystemIFileSystemReffile_systemIFileSystemReffileSystemIFileSystemRefFileSystemIFileSystemRefFileSystemIFileSystemRefrequired#The EFS File System that supports this volume.
the name of this volume.
readonlyoptionalbooleanreadonlyoptionalboolreadonlyoptionalBooleanReadonlyoptionalboolReadonlyoptional*bool= false#if set, the container will have readonly access to the volume.
rootDirectoryoptionalstringroot_directoryoptionalstrrootDirectoryoptionalStringRootDirectoryoptionalstringRootDirectoryoptional*string#The directory within the Amazon EFS file system to mount as the root directory inside the host.
Default: root of the EFS File System
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.
transitEncryptionPortoptionalnumbertransit_encryption_portoptionalint | floattransitEncryptionPortoptionalNumberTransitEncryptionPortoptionaldoubleTransitEncryptionPortoptional*float64#The port to use when sending encrypted data between the Amazon ECS host and the Amazon EFS server.
Default: chosen by the EFS Mount Helper
The value must be between 0 and 65,535.
useJobRoleoptionalbooleanuse_job_roleoptionalbooluseJobRoleoptionalBooleanUseJobRoleoptionalboolUseJobRoleoptional*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.