EcsVolume Class
Represents a Volume that can be mounted to a container that uses ECS.
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,
}),
});
Initializer
ts
new EcsVolume(options: EcsVolumeOptions)
python
EcsVolume(options: EcsVolumeOptions)
java
new EcsVolume(EcsVolumeOptions options)
csharp
new EcsVolume(EcsVolumeOptions options)
go
NewEcsVolume(Options EcsVolumeOptions)
Properties
containerPathstringcontainer_pathstrcontainerPathStringContainerPathstringContainerPath*stringrequired#The path on the container that this volume will be mounted to.
The name of this volume.
Whether or not the container has readonly access to this volume.
Methods
efs(options: EfsVolumeOptions): EfsVolume@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.