s3-empty-bucket
v1.0.0-alpha.8
Published
Library and CLI to quickly empty AWS S3 buckets.
Downloads
32
Maintainers
Readme
s3-empty-bucket
DO NOT USE FOR THE MOMENT. There's a bug in the code that may result in excessive API calls. We will address later today.
Special notice ends.
Library and CLI to quickly empty AWS S3 buckets.
While we expect this library to work in most cases, it has not been extensively tested. However, we actively support this library so please submit any issues and we'll be happy to look into it.
Installation
To install the library:
npm i --omit peer s3-empty-bucket # peer deps only needed for CLI
To install the CLI (globally):
npm i -g s3-empty-bucket
Usage
Library
import { S3Client } from '@aws-sdk/client-s3'
import { fromIni } from '@aws-sdk/credential-providers'
import { emptyBucket } from 's3-empty-bucket' // ES6
// const { emptyBucket } = require('s3-empty-bucket') // cjs
// following works with API keys, include the profile when using SSO sessions
const credentials = fromIni(/* { profile : ssoProfile }*/)
const s3Client = new S3Client({ credentials })
emptyBucket({ bucketName, s3Client, verbose: false })
CLI
# following works with API keys, include the profile when using SSO sessions
s3-empty-bucket my-bucket-name # --profile your-sso-profile
API Reference
API generated with dmd-readme-api.
emptyBucket(options)
Empties AWS S3 bucket.
| Param | Type | Description |
| --- | --- | --- |
| options | object
| The destructured options object. |
| options.bucketName | string
| The name of the bucket to empty. |
| options.doDelete | boolean
| If true, then deletes the bucket after emptying it. |
| options.s3Client | object
| Authenticated S3Client
. |
| options.verbose | boolean
| When true, will report actions to process.stdout
. |
CLI command reference
Usage
s3-empty-bucket <options> [bucketName]
Options
|Option|Description|
|------|------|
|[bucketName]
|(main argument,required) The name of the bucket to empty.|
|--delete
|Deletes the bucket after emptying it.|
|--document
|Generates command line documentation in Markdown format. All other options are ignored.|
|--help
, -?
|Prints command help.|
|--profile
, -p
|The SSO profile to use.|
|--quiet
, -q
|Suppresses output.|
|--throw-error
|Instead of printing simple message, allows exceptions to bubble up to the user.|
Contributing
Plase feel free to submit any bug reports or feature suggestions. You're also welcome to submit patches of course. We don't have a full contributors policy yet, but you can post questions on our discord channel. It's not monitored 24/7, but you should hear back from us by next business day generally.
Support and feature requests
The best way to get free support is to submit a ticket. You can also become a patron for as little as $1/month and get priority support and request new feature on all Liquid Labs open source software. You can get these benefits and support our work at patreon.com/zanecodes.