Skip to content

Instantly share code, notes, and snippets.

@losvedir
losvedir / rspec_magic.rb
Last active December 25, 2015 22:39
Exploration into how Rspec could provide some of its nice syntactical features
require 'ostruct'
class Object
def expect(value)
@expector = Expector.new(value)
end
def eq(val)
[:==, val]
end
@losvedir
losvedir / ecr_cleanup.md
Last active May 25, 2022 19:15
Clean up old ECR images

Cleaning up old ECR images

A process to delete old ECR images using the aws CLI tool and jq.

The general idea is to use aws ecr describe-images to enumerate the images, and aws ecr batch-delete-image to delete them. The latter command can take a --cli-input-json argument specifying a JSON file which lists the images to delete. jq is used to filter describe-images to only the old ones, and munge it into the format that batch-delete-image expects. Unfortunately, batch-delete-image supports a maximum of 100 images at a time, so the process may need to be repeated several times.

Limitations:

  • I can't find a way to do this as a neat command line pipeline. --cli-input-json seems to require that the input comes from a file, rather than STDIN. (AWS CLI tracking issue: aws/aws-cli#3209)
  • Since batch-delete-image can only handle 100 images at a time, the jq command slices to [0:100] after filtering to just the old images. This means the process may have to be re