# EfsVolume

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

this volume can grow and shrink as needed

Extends: [EcsVolume](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EcsVolume.html) › EfsVolume
Obtainable from: [EcsVolume.efs](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EcsVolume.html#efs)

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

## Example

TypeScript:

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

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

```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();
```

C# / .NET:

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

Golang:

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

TypeScript:

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

Python:

```python
EfsVolume(options: EfsVolumeOptions)
```

Java:

```java
new EfsVolume(EfsVolumeOptions options)
```

C# / .NET:

```csharp
new EfsVolume(EfsVolumeOptions options)
```

Golang:

```go
NewEfsVolume(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](https://docs.aws.amazon.com/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.
