Skip to content

Elastic File System (EFS)

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, which provides information on the extent of EFS’s integration with LocalStack.

This guide is designed for users new to Elastic File System and assumes basic knowledge of the AWS CLI and our awslocal wrapper script.

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.

To create a new, empty file system you can use the CreateFileSystem API. Run the following command to create a new file system:

Terminal window
awslocal efs create-file-system \
--performance-mode generalPurpose \
--throughput-mode bursting \
--encrypted \
--tags Key=Name,Value=my-file-system
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 API. Run the following command to describe the local file systems available:

Terminal window
awslocal 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.

You can apply an EFS FileSystemPolicy to an EFS file system using the PutFileSystemPolicy API. Run the following command to apply a policy to the file system created in the previous step:

Terminal window
awslocal 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 API. Run the following command to list the file system policies:

Terminal window
awslocal 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.

You can create a lifecycle configuration for an EFS file system using the PutLifecycleConfiguration API. Run the following command to create a lifecycle configuration for the file system created in the previous step:

Terminal window
awslocal efs put-lifecycle-configuration \
--file-system-id <FILE_SYSTEM_ID> \
--lifecycle-policies "{\"TransitionToIA\":\"AFTER_30_DAYS\"}"
Output
{
"LifecyclePolicies": [
{
"TransitionToIA": "AFTER_30_DAYS"
}
]
}

LocalStack’s EFS implementation is limited and lacks support for functionalities like creating mount targets, configuring access points, and generating tags. LocalStack uses Moto to emulate the EFS APIs, and efforts are underway to incorporate support for these features in upcoming updates.

OperationImplementedImage
Page 1 of 0