Menu
AWS Tools for Windows PowerShell
User Guide

Delete Amazon S3 Objects and Buckets

This section describes how to delete the website that you created in preceding sections. You can simply delete the objects for the HTML files, and then delete the Amazon S3 bucket for the site.

Run the Remove-S3Object cmdlet to delete the objects for the HTML files from the Amazon S3 bucket.

PS C:\> foreach ( $obj in "index.html", "error.html" ) { >> Remove-S3Object -BucketName website-example -Key $obj >> } >> IsDeleteMarker -------------- False

The False response is an expected artifact of the way that Amazon S3 processes the request. In this context, it does not indicate an issue.

Run the Remove-S3Bucket cmdlet to delete the now-empty Amazon S3 bucket for the site.

PS C:\> Remove-S3Bucket -BucketName website-example RequestId : E480ED92A2EC703D AmazonId2 : k6tqaqC1nMkoeYwbuJXUx1/UDa49BJd6dfLN0Ls1mWYNPHjbc8/Nyvm6AGbWcc2P ResponseStream : Headers : {x-amz-id-2, x-amz-request-id, Date, Server} Metadata : {} ResponseXml :

In 1.1 and newer versions of the Tools for Windows PowerShell, you can add the -DeleteBucketContent parameter to Remove-S3Bucket, which first deletes all objects and object versions in the specified bucket before trying to remove the bucket itself. Depending on the number of objects or object versions in the bucket, this operation can take a substantial amount of time. In versions of the Tools for Windows PowerShell older than 1.1, the bucket had to be empty for Remove-S3Bucket to delete it.

Note that unless you add the -Force parameter, you are prompted for confirmation before the cmdlet runs.

See Also

On this page: