go/example_code/s3/delete-buckets-by-prefix/README.md
This example demonstrates how to delete all of the Amazon S3 buckets you own that begin with a given prefix.
You must have an AWS account, and have your default credentials and AWS Region configured as described in Configuring the AWS SDK for Go in the AWS SDK for Go Developer Guide.
go run s3_delete_buckets -p PREFIX
For example, if you call go run s3_delete_buckets.go -p dummy-,
it first removes all of the objects in the Amazon S3 buckets with names starting with dummy-,
then deletes all of those S3 buckets.
Unit tests should delete any resources they create. However, they might result in charges to your AWS account.
The unit test:
To run the unit test, enter:
go test
You should see something like the following, where PATH is the path to folder containing the Go files:
PASS
ok PATH 6.593s
If you want to see any log messages, enter:
go test -test.v
You should see some additional log messages. The last two lines should be similar to the previous output shown.
You can confirm it has deleted any resources it created by running:
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0