Skip to content
Get Started for Free

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 lstk 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.

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
lstk aws 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
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.

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

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

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
lstk aws efs put-lifecycle-configuration \
--file-system-id <FILE_SYSTEM_ID> \
--lifecycle-policies "{\"TransitionToIA\":\"AFTER_30_DAYS\"}"
Output
{
"LifecyclePolicies": [
{
"TransitionToIA": "AFTER_30_DAYS"
}
]
}

LocalStack uses Moto to emulate the EFS APIs. The legacy CreateTags, DeleteTags, and DescribeTags operations are not supported; use TagResource, UntagResource, and ListTagsForResource instead.

23 of 31 operations implemented

Available from the Ultimate plan. Licensing details

Find an API

Search the full operation list, then sort the table to compare current support.

Loading operations…

Verified on Kubernetes
Loading operations…
Complete static API list All 31 operations and their current support status
OperationStatus
CreateAccessPointImplemented
CreateFileSystemImplemented
CreateMountTargetImplemented
CreateReplicationConfigurationNot implemented
CreateTagsNot implemented
DeleteAccessPointImplemented
DeleteFileSystemImplemented
DeleteFileSystemPolicyImplemented
DeleteMountTargetImplemented
DeleteReplicationConfigurationNot implemented
DeleteTagsNot implemented
DescribeAccessPointsImplemented
DescribeAccountPreferencesNot implemented
DescribeBackupPolicyImplemented
DescribeFileSystemPolicyImplemented
DescribeFileSystemsImplemented
DescribeLifecycleConfigurationImplemented
DescribeMountTargetSecurityGroupsImplemented
DescribeMountTargetsImplemented
DescribeReplicationConfigurationsNot implemented
DescribeTagsNot implemented
ListTagsForResourceImplemented
ModifyMountTargetSecurityGroupsImplemented
PutAccountPreferencesNot implemented
PutBackupPolicyImplemented
PutFileSystemPolicyImplemented
PutLifecycleConfigurationImplemented
TagResourceImplemented
UntagResourceImplemented
UpdateFileSystemImplemented
UpdateFileSystemProtectionImplemented
Was this page helpful?