Articles on: Object storage

AWS CLI: advanced bucket management

Prerequisites


Install AWS CLI
Have created your Leviia credentials in your dashboard

AWS CLI configuration :


aws configure

AWS Access Key ID [****************ofuW] : your_access_key
AWS Secret Access Key [****************25qt] : your_secret_key
Default region name [france]: france
Default output format [None]: leave this field empty

List buckets :


aws s3 ls --endpoint-url https://s3.leviia.com

List objects in a bucket :


aws s3api list-objects --bucket bucket_name --endpoint-url https://s3.leviia.com

List all versions in a bucket :


aws s3api list-object-versions --bucket bucket_name --endpoint-url https://s3.leviia.com

List object versions :


aws s3api list-object-versions --bucket bucket_name --prefix file_name --endpoint-url https://s3.leviia.com



It is not possible to delete a locked object

Permanently delete the version of an object on the bucket :


aws s3api delete-object --bucket bucket_name --key file_name --version-id id_of_version (of the file version and not of the delete marker for permanent deletion) --endpoint-url https://s3.leviia.com

If the version is locked, the API will return an error.

Restore an object deleted on your bucket but having a Delete Marker :


aws s3api delete-object --bucket bucket_name --key file_name --version-id id_of_the_version_of_the_delete_marker_of_the_file --endpoint-url https://s3.leviia.com



Delete a bucket :


aws s3 rb s3://bucket_name --force --endpoint-url https://s3.leviia.com

If the bucket contains locked objects, the API will return an error.

Delete all files in a bucket :


aws s3 rm s3://bucket_name --recursive --endpoint-url https://s3.leviia.com

If the bucket contains locked objects, the API will also return an error.

Delete all .doc files in a bucket :


aws s3 rm s3://bucket_name/doc --recursive --endpoint-url https://s3.leviia.com

Updated on: 05/01/2024

Was this article helpful?

Share your feedback

Cancel

Thank you!