Skip to content

Object Versioning object operations

Estimated time to read: 1 minute

On this page you can find information about using Object Versioning object operations.

Creating objects with Object Versioning requires a bucket with Object Versioning enabled. Enable Object Versioning.

Object Versioning

List objects

To list all non soft deleted objects:

aws s3api list-objects --bucket <bucket-name

To list all objects:

aws s3api list-object-versions --bucket <bucket_name>

Retrieve a subset of objects

To filter output you can use --prefix <value> to retrieve only a subset.

For example:

aws s3api list-object-versions --bucket <bucket_name> --prefix <object_name>

Get an Object Version

To get a specific object by its version:

aws s3api get-object --bucket <bucket_name> --key <object_name> --version-id <version_id> <local_file_path>

Soft delete an Object

To soft delete an object:

aws s3api delete-object --bucket <bucket_name> --key <object_name>
This will create a deletion marker, the object will still exist although not visible with list-objects.

Delete an Object

To delete an object, that is versioned, it is required to use the version-id:

aws s3api delete-object --bucket <bucket_name> --key <object_name> --version-id <version_id>

To delete the metadata of a soft deleted object, it is required to also delete the delete marker.