Deleting versions from a Linode s3 bucket

Deleting versions from a Linode s3 bucket
Photo by Lubomirkin / Unsplash

So...this wasn't as straight forward as I thought...


Enabling versioning for s3 buckets is standard practice for terraform's s3 backend, which Linode supports...kind of... While yes technically Linode supports the versioning, it doesn't support deleting the versions from the web-ui... 🤦.

Alright, that's fine I've heard they have a CLI...surely they'll support deleting it from there, right?

Ok...ok...just one more package and...

GAHHH...this was very frustrating... (source)


I use pipx for all my binaries I install, so that's what I'll use for installing python pip package, if you only want to use pip it's pretty much the exact same (just pip install boto instead of pipx inject linode-cli boto.

pipx install linode-cli
# authenticate with PAT (personal access token)
linode-cli configure --token
pipx inject linode-cli boto
# validate able to reach linode buckets
linode-cli obj ls

pipx install awscli
# used for aws auth
cat ~/.config/linode-cli
aws configure

aws s3api delete-objects --endpoint= --bucket=<bucket_name> --delete "$(aws s3api list-object-versions --endpoint= --bucket "<bucket_name>" --output=json --query='{Objects: Versions[].{Key:Key,VersionId:VersionId}}')"
aws s3 rm --endpoint-url=  --recursive s3://<bucket_name>


alright, well this is now a guide for me when I need to delete versioned object out of Linode's s3 object storage... 🤦