Skip to main content

Amazon EFS (amazon-efs) allows programmatically manipulate EFS data (create, read, delete, list files) from any machine.

Project description

Amazon EFS (amazon-efs)

Amazon EFS (amazon-efs) allows programmatically manipulate EFS data (create, read, delete, list files) from any machine.

Prerequisites

  • python
  • pip
  • boto3
  • AWS Account
  • AWS Credentials

Install

pip install amazon-efs

Warning

EFS should have at least one mount target in a Private subnet

Limits

list_files, upload, download, delete actions are limited by 15 minutes execution time (AWS Lambda works under the hood)

Basics

from amazon_efs import Efs

efs_id = 'fs-0d74736bfc*******'
efs = Efs(efs_id)

# Deploying required underlying resources
efs.init()
# Actions (e.g. list_files, upload, download, delete)
files_list = efs.list_files()
# Don't forget to destroy underlying resources at the end of the session
efs.destroy()

Actions

List files

from amazon_efs import Efs

efs_id = 'fs-0d74736bfc*******'
efs = Efs(efs_id)

efs.init()

files_list = efs.list_files()
print(files_list)
files_list = efs.list_files('dir1')
print(files_list)
files_list = efs.list_files('dir1/dir2')
print(files_list)

efs.destroy()

Upload

from amazon_efs import Efs

efs_id = 'fs-0d74736bfc*******'
efs = Efs(efs_id)

efs.init()

efs.upload('file.txt')
efs.upload('file.txt', 'dir1/new_file.txt')
efs.upload('file.txt', 'dir1/dir2/new_file.txt')
efs.upload('file.txt', 'dir1/dir3/new_file.txt')
efs.upload('file.txt', 'dir2/dir3/new_file.txt')
efs.upload('file.txt', 'dir2/dir4/new_file.txt')

efs.destroy()

Download

from amazon_efs import Efs

efs_id = 'fs-0d74736bfc*******'
efs = Efs(efs_id)

efs.init()

efs.download('dir1/dir3/new_file.txt', 'file1.txt')

efs.destroy()

Delete

Delete file

from amazon_efs import Efs

efs_id = 'fs-0d74736bfc*******'
efs = Efs(efs_id)

efs.init()

efs.delete('dir2/dir3/new_file.txt')

efs.destroy()

Delete folder

from amazon_efs import Efs

efs_id = 'fs-0d74736bfc*******'
efs = Efs(efs_id)

efs.init()

efs.delete('dir1/dir2/*')
efs.delete('dir1/*')

efs.destroy()

State

You can destroy underlying infrastructure even after destroying EFS object from RAM if you saved the state

from amazon_efs import Efs

efs_id = 'fs-0d74736bfc*******'
efs = Efs(efs_id)

state = efs.init()

# Destroy object
del efs

efs = Efs(efs_id, { 'state': state })

files_list = efs.list_files()
print(files_list)

efs.destroy()

Tags

You can add custom tags to underlying resources

from amazon_efs import Efs

efs_id = 'fs-0d74736bfc*******'
efs = Efs(efs_id, {
    'tags': {
        'k1': 'v1',
        'k2': 'v2'
    }
})

efs.init()

files_list = efs.list_files()
print(files_list)

efs.destroy()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

amazon-efs-0.0.14.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

amazon_efs-0.0.14-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file amazon-efs-0.0.14.tar.gz.

File metadata

  • Download URL: amazon-efs-0.0.14.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.6 tqdm/4.63.1 importlib-metadata/4.10.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.12

File hashes

Hashes for amazon-efs-0.0.14.tar.gz
Algorithm Hash digest
SHA256 998b833ea357e8a3f8444662ba7c0026a1708223293cf93a7078805f0197a4ab
MD5 9b7e4039f2ff9878387fb2a6ccd88821
BLAKE2b-256 6d0ffe87c18b03c6940c775d7288595970384060eb592d2155f34c64ddffc2d5

See more details on using hashes here.

File details

Details for the file amazon_efs-0.0.14-py3-none-any.whl.

File metadata

  • Download URL: amazon_efs-0.0.14-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.6 tqdm/4.63.1 importlib-metadata/4.10.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.12

File hashes

Hashes for amazon_efs-0.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 d2aa2f9a00d71e13f22f7acd4b9cb6bf389f694b5a4b2a45e449b10729155874
MD5 b7a6da291f3f87dbac382d7e6cfe07d4
BLAKE2b-256 719bb15ec9a5c964e93cd46a8a401edd35ba4de62b5ace1b22fc76ad10563337

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page