Linked List

A personal knowledge base

Delete in Bulk from S3

Given a list of objects to delete the following Ruby snippet will delete them in batches of 100:

# ruby
require 'shellwords'

ARGF.lines.each_slice(100) do |slice|
  system "aws --profile bellroy s3 rm #{slice.map { |l| l.strip.shellescape }.join(' ')}"
end

Input file looks like:

s3://files.bellroy.com/E1HJ4ISXVG05CA.2015-02-23-15.c074f93f.gz
s3://files.bellroy.com/E1HJ4ISXVG05CA.2015-02-23-15.d3d2a169.gz
s3://files.bellroy.com/E1HJ4ISXVG05CA.2015-02-23-21.02ed8e8d.gz
Last modified: 21 October 2015