aws-s3-rm
Remove objects from Amazon S3 buckets
TLDR
Delete a specific S3 object
Preview the deletion of a specific S3 object without deleting it (dry-run)
Delete an object from a specific S3 access point
Remove all objects from a bucket (empty the bucket)
Display help
SYNOPSIS
aws s3 rm
PARAMETERS
S3Uri
The S3 URI of the object or prefix to remove (e.g., `s3://bucket/key` or `s3://bucket/prefix/`).
--recursive
Recursively remove all objects under the specified prefix. This is required for deleting prefixes containing multiple objects.
--dryrun
Performs the operation without actually deleting any objects. This is useful for previewing the effects of the command.
--exclude
Exclude objects during recursive operations. Provide a glob-style pattern. Can be specified multiple times to specify multiple rules.
--include
Include objects during recursive operations. Provide a glob-style pattern. Can be specified multiple times to specify multiple rules.
--only-show-errors
Only errors are displayed, otherwise all output is suppressed.
--profile
The AWS profile to use (if configured).
--region
The AWS region to use.
DESCRIPTION
The `aws s3 rm` command is a powerful tool provided by the AWS Command Line Interface (CLI) for deleting objects from Amazon Simple Storage Service (S3) buckets. It allows users to remove individual objects, entire prefixes (folders), or recursively delete all content within a bucket or prefix. This command supports versioning. When versioning is enabled, you must use a different command to remove particular versions.
CAVEATS
Using `aws s3 rm --recursive` without caution can lead to unintended data loss. Always double-check the S3 URI before executing the command.
Removing versioned objects requires specific commands. This command is intended to permanently delete the object.
EXAMPLES
Remove a single object:aws s3 rm s3://my-bucket/my-object.txt
Remove all objects under a prefix:aws s3 rm s3://my-bucket/my-prefix/ --recursive
Dry run to preview the effect of recursive removal:aws s3 rm s3://my-bucket/my-prefix/ --recursive --dryrun
Remove all .txt except test.txt files from s3://my-bucket/test/:aws s3 rm s3://my-bucket/test/ --recursive --exclude "*" --include "*.txt" --exclude "test.txt"