Giter Club home page Giter Club logo

s3-cloudfront-batch-delete's Introduction

S3 & Cloudfront Batch Delete

This .NET console app reads a text file of filenames to be deleted from an AWS S3 Bucket. It is used for batch processing of large amount of files that would otherwise take too long to delete one by one.

Thumbnail images or other secondary files can be optionally deleted alongside the main files.

A related Cloudfront CDN can also invalidate its cache of the deleted S3 files.

Setup

appsettings.json needs to be created with the following variables:

{
  "AWS_ACCESS_KEY": "",
  "AWS_SECRET_KEY": "",
  "S3_BUCKET": "",
  "S3_PATH": "",
  "S3_SECONDARY_PATH": "<optional>",  
  "CDN_DISTRIBUTION_ID": "<optional>"
}

AWS Credentials will need to have IAM permissions to list and delete from S3, and optionally have invalidation permission for Cloudfront.

Example Input

An example text file FileNamesToDelete.txt containing:

122402.jpg
543212.jpg
file3.pdf
file4.png

Would result in 4 files being batch deleted from the S3 bucket and path specified in appsettings.json.

If a S3_SECONDARY_PATH is set, any files with the same filename will be deleted from S3. This is useful for thumbnail images with the same filename, but different paths.

If CDN_DISTRIBUTION_ID is set, any Cloudfront CDN associated files will also be invalidated. The ID can be obtained from https://us-east-1.console.aws.amazon.com/cloudfront.

s3-cloudfront-batch-delete's People

Contributors

jason-nzd avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.