# EfsVolume

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

this volume can grow and shrink as needed

Extends: EcsVolume › EfsVolume

- 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#L241)
- Type last changed: v2.96.0 · 13 Sep 2023

## 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,
});
```

## Initializer

```ts
new EfsVolume(options: EfsVolumeOptions)
```

## Properties

- `accessPointId`: 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`.

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

- `enableTransitEncryption`: boolean = false — Enables encryption for Amazon EFS data in transit between the Amazon ECS host and the Amazon EFS server.

- `fileSystem`: [IFileSystem](/cdk/api/v2/docs/aws-cdk-lib.aws_efs.IFileSystem.html) — The EFS File System that supports this volume.

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

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

- `rootDirectory`: 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.

- `transitEncryptionPort`: number — 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.

- `useJobRole`: boolean = 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` (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.

- `isEfsVolume(x: any): boolean` (static) — Returns true if x is an EfsVolume, false otherwise.
