# EcsVolume

Represents a Volume that can be mounted to a container that uses ECS.

Extends: EcsVolume
Superclass of: EfsVolume, HostVolume

- Source: [`aws-batch/lib/ecs-container-definition.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-batch/lib/ecs-container-definition.ts#L134)
- Type last changed: v2.96.0 · 13 Sep 2023

## 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)
```

## Properties

- `containerPath`: string — The path on the container that this volume will be mounted to.

- `name`: string — The name of this volume.

- `readonly`: boolean = false — Whether or not the container has readonly access to this volume.

## Methods

- `efs(options: EfsVolumeOptions): EfsVolume` (static) — Creates a Volume that uses an AWS Elastic File System (EFS);

  this volume can grow and shrink as needed

- `host(options: HostVolumeOptions): HostVolume` (static) — 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.
