JSPM

serverless-s3-cleaner

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 24501
  • Score
    100M100P100Q146998F
  • License MIT

Serverless Framework plugin that empties S3 buckets before removing a stack

Package Exports

  • serverless-s3-cleaner

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (serverless-s3-cleaner) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

serverless-s3-cleaner

serverless license build status npm version

Serverless Framework plugin that empties an S3 bucket before removing a deployed stack. Replacement for serverless-s3-remover which is no longer maintained.

Installation

npm install serverless-s3-cleaner --save-dev

Usage

Add the following to your serverless.yml:

plugins:
  - serverless-s3-cleaner

custom:
  serverless-s3-cleaner:
    # (optional) Whether to prompt before emptying a bucket. Default is 'false'.
    prompt: false

    # Names of buckets to remove before a stack is removed, or via 'sls s3clean' command
    buckets:
      - bucketName1
      - bucketName2

    # (optional) Buckets to remove before a stack is deployed.
    bucketsToRemoveOnDeploy:
      - oldBucketName

When removing a Serverless Framework stack, this plugin automatically empties the buckets listed under buckets option.

When deploying a Serverless Framework stack, this plugin automatically empties the buckets listed under bucketsToRemoveOnDeploy option. Use this when renaming or removing a bucket (put here the old bucket name) to avoid deployment errors when CloudFormation tries to remove the old bucket.

You can also empty a bucket explicitly by running:

sls s3remove

Versioning

Buckets with versioning enabled are supported. When emptying a bucket, all object versions and delete markers are deleted.

IAM Permissions

The plugin requires the following permissions to be given to the role that Serverless runs under, for all the affected buckets:

  • s3:ListBucket
  • s3:ListBucketVersions
  • s3:DeleteObject
  • s3:DeleteObjectVersion