Skip to content

Instantly share code, notes, and snippets.

@RagedUnicorn
Created August 2, 2023 10:18
Show Gist options
  • Save RagedUnicorn/81a332d9e01d7c51a74a24ecae95abfa to your computer and use it in GitHub Desktop.
Save RagedUnicorn/81a332d9e01d7c51a74a24ecae95abfa to your computer and use it in GitHub Desktop.
Cleanup AWS S3 Bucket
$Bucket = "ragedunicorn-ai"
$Prefix = "work/gressil_reimagined/"
$Objects = aws s3api list-object-versions --bucket $Bucket --prefix $Prefix | ConvertFrom-Json
ForEach ($Object in $Objects.Versions) {
Write-Output "Deleting object: $($Object.Key), version: $($Object.VersionId)"
aws s3api delete-object --bucket $Bucket --key $Object.Key --version-id $Object.VersionId
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment