# Elastic File System (EFS)

Source: /aws/services/efs/

## Introduction

Elastic File System (EFS) is a fully managed file storage service provided by Amazon Web Services (AWS).
EFS offers scalable and shared file storage that can be accessed by multiple EC2 instances and on-premises servers simultaneously.
EFS utilizes the Network File System protocol to allow it to be used as a data source for various applications and workloads.

LocalStack allows you to use the EFS APIs in your local environment to create local file systems, lifecycle configurations, and file system policies.
The supported APIs are available on our [API Coverage section](#api-coverage), which provides information on the extent of EFS's integration with LocalStack.

## Getting started

This guide is designed for users new to Elastic File System and assumes basic knowledge of the AWS CLI and our [`lstk aws`](/aws/developer-tools/running-localstack/lstk/cloud-and-iac-commands/#aws) command.

Start your LocalStack container using your preferred method.
We will demonstrate how to create a file system, apply an IAM resource-based policy, and create a lifecycle configuration using the AWS CLI.

### Create a filesystem

To create a new, empty file system you can use the [`CreateFileSystem`](https://docs.aws.amazon.com/goto/WebAPI/elasticfilesystem-2015-02-01/CreateFileSystem) API.
Run the following command to create a new file system:

```bash
lstk aws efs create-file-system \
    --performance-mode generalPurpose \
    --throughput-mode bursting \
    --encrypted \
    --tags Key=Name,Value=my-file-system
```

```bash title="Output"
{
    "CreationToken": "53465731-0032-4cef-92f5-8aefe7c7b91e",
    "FileSystemId": "fs-34feac549e66b814",
    "FileSystemArn": "arn:aws:elasticfilesystem:us-east-1:000000000000:file-system/fs-34feac549e66b814",
    "CreationTime": 1692808338.424,
    "LifeCycleState": "available",
    "PerformanceMode": "generalPurpose",
    "Encrypted": true,
    "ThroughputMode": "bursting",
    "Tags": [
        {
            "Key": "Name",
            "Value": "my-file-system"
        }
    ]
}
```

You can also describe the locally available file systems using the [`DescribeFileSystems`](https://docs.aws.amazon.com/efs/latest/ug/API_DescribeFileSystems.html) API.
Run the following command to describe the local file systems available:

```bash
lstk aws efs describe-file-systems
```

You can alternatively pass the `--file-system-id` parameter to the `describe-file-system` command to retrieve information about a specific file system in AWS CLI.

### Put file system policy

You can apply an EFS `FileSystemPolicy` to an EFS file system using the [`PutFileSystemPolicy`](https://docs.aws.amazon.com/efs/latest/ug/API_PutFileSystemPolicy.html) API.
Run the following command to apply a policy to the file system created in the previous step:

```bash
lstk aws efs put-file-system-policy \
    --file-system-id <FILE_SYSTEM_ID> \
    --policy "{\"Version\":\"2012-10-17\",\"Id\":\"ExamplePolicy01\",\"Statement\":[{\"Sid\":\"ExampleStatement01\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":[\"elasticfilesystem:ClientMount\",\"elasticfilesystem:ClientWrite\"],\"Resource\":\"arn:aws:elasticfilesystem:us-east-1:000000000000:file-system/fs-34feac549e66b814\"}]}"
```

You can list the file system policies using the [`DescribeFileSystemPolicy`](https://docs.aws.amazon.com/efs/latest/ug/API_DescribeFileSystemPolicy.html) API.
Run the following command to list the file system policies:

```bash
lstk aws efs describe-file-system-policy \
    --file-system-id <FILE_SYSTEM_ID>
```

Replace `<FILE_SYSTEM_ID>` with the ID of the file system you want to list the policies for.
The output will return the `FileSystemPolicy` for the specified EFS file system.

### Create a lifecycle configuration

You can create a lifecycle configuration for an EFS file system using the [`PutLifecycleConfiguration`](https://docs.aws.amazon.com/efs/latest/ug/API_PutLifecycleConfiguration.html) API.
Run the following command to create a lifecycle configuration for the file system created in the previous step:

```bash
lstk aws efs put-lifecycle-configuration \
    --file-system-id <FILE_SYSTEM_ID> \
    --lifecycle-policies "{\"TransitionToIA\":\"AFTER_30_DAYS\"}"
```

```bash title="Output"
{
    "LifecyclePolicies": [
        {
            "TransitionToIA": "AFTER_30_DAYS"
        }
    ]
}
```

## Current Limitations

LocalStack uses Moto to emulate the EFS APIs.
The legacy [`CreateTags`](https://docs.aws.amazon.com/efs/latest/ug/API_CreateTags.html), [`DeleteTags`](https://docs.aws.amazon.com/efs/latest/ug/API_DeleteTags.html), and [`DescribeTags`](https://docs.aws.amazon.com/efs/latest/ug/API_DescribeTags.html) operations are not supported; use [`TagResource`](https://docs.aws.amazon.com/efs/latest/ug/API_TagResource.html), [`UntagResource`](https://docs.aws.amazon.com/efs/latest/ug/API_UntagResource.html), and [`ListTagsForResource`](https://docs.aws.amazon.com/efs/latest/ug/API_ListTagsForResource.html) instead.

## API Coverage


### Elastic File System API coverage

Source service: `efs`. 23 of 31 tracked operations are implemented.

Service documentation: /aws/services/efs/
License availability: available starting with the Ultimate plan. See /aws/licensing/ for current plan details.

| Operation | Status |
| --- | --- |
| CreateAccessPoint | Implemented |
| CreateFileSystem | Implemented |
| CreateMountTarget | Implemented |
| CreateReplicationConfiguration | Not implemented |
| CreateTags | Not implemented |
| DeleteAccessPoint | Implemented |
| DeleteFileSystem | Implemented |
| DeleteFileSystemPolicy | Implemented |
| DeleteMountTarget | Implemented |
| DeleteReplicationConfiguration | Not implemented |
| DeleteTags | Not implemented |
| DescribeAccessPoints | Implemented |
| DescribeAccountPreferences | Not implemented |
| DescribeBackupPolicy | Implemented |
| DescribeFileSystemPolicy | Implemented |
| DescribeFileSystems | Implemented |
| DescribeLifecycleConfiguration | Implemented |
| DescribeMountTargetSecurityGroups | Implemented |
| DescribeMountTargets | Implemented |
| DescribeReplicationConfigurations | Not implemented |
| DescribeTags | Not implemented |
| ListTagsForResource | Implemented |
| ModifyMountTargetSecurityGroups | Implemented |
| PutAccountPreferences | Not implemented |
| PutBackupPolicy | Implemented |
| PutFileSystemPolicy | Implemented |
| PutLifecycleConfiguration | Implemented |
| TagResource | Implemented |
| UntagResource | Implemented |
| UpdateFileSystem | Implemented |
| UpdateFileSystemProtection | Implemented |
