> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://wiki.leviia.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# AWS CLI: advanced bucket management

## Prerequisites
* [Install AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)
* [Have created your Leviia credentials in your dashboard ](https://wiki.leviia.com/en/article/create-object-storage-identifier-in-your-leviia-dashboard-1as7ljn/)

## AWS CLI configuration :
aws configure
![](https://storage.crisp.chat/users/helpdesk/website/7181a953295a4800/2023-11-2910-20_ghc4m7.png)
AWS Access Key ID [**********ofuW] : ${color}[#e01b24](**your_access_key**)
AWS Secret Access Key [**********25qt] : ${color}[#e01b24](**your_secret_key**)
Default region name [france]: ${color}[#e01b24](**france**)
Default output format [None]: leave this field empty

## List buckets : 
aws s3 ls --endpoint-url  https://(leviia endpoint)

## List objects in a bucket : 
aws s3api list-objects --bucket ${color}[#e01b24](**bucket_name**) --endpoint-url https:// ${color}[#e01b24](**your_endpoint**) 

## List all versions in a bucket :
aws s3api list-object-versions --bucket ${color}[#e01b24](**bucket_name**) --endpoint-url https:// ${color}[#e01b24](**your_endpoint**) 

## List object versions :
aws s3api list-object-versions --bucket ${color}[#e01b24](**bucket_name**) --prefix ${color}[#e01b24](**file_name**) --endpoint-url https:// ${color}[#e01b24](**your_endpoint**) 

![](https://storage.crisp.chat/users/helpdesk/website/7181a953295a4800/2023-11-1612-00_l64f9q.png)

||| It is not possible to delete a locked object

## Permanently delete the version of an object on the bucket :
aws s3api delete-object --bucket ${color}[#e01b24](**bucket_name**) --key ${color}[#e01b24](file_name) --version-id ${color}[#e01b24](**id_of_version**) (of the file version and not of the delete marker for permanent deletion) --endpoint-url https:// ${color}[#e01b24](**your_endpoint**) 

|| 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 ${color}[#e01b24](**bucket_name**) --key ${color}[#e01b24](file_name) --version-id ${color}[#e01b24](**id_of_the_version_of_the_delete_marker_of_the_file**) --endpoint-url  https:// ${color}[#e01b24](**your_endpoint**) 

![](https://storage.crisp.chat/users/helpdesk/website/7181a953295a4800/2023-11-2909-40_lklg9i.png)

## Delete a bucket :
aws s3 rb ${color}[#e01b24](**s3://bucket_name**) --force --endpoint-url https:// ${color}[#e01b24](**your_endpoint**) 

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

## Delete all files in a bucket :
aws s3 rm ${color}[#e01b24](**s3://bucket_name**) --recursive --endpoint-url https:// ${color}[#e01b24](**your_endpoint**) 

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

## Delete all .doc files in a bucket :
aws s3 rm ${color}[#e01b24](**s3://bucket_name/doc**) --recursive --endpoint-url https:// ${color}[#e01b24](**your_endpoint**) 