WORKFLOW

Terminate EC2 instances without valid lifetime tag

Use this workflow

This workflow looks at all of the EC2 instances in a given account and region and selects a subset of those to terminate. Requires an AWS account with permissions to delete EC2 instances. The termination criteria are:

  • Not tagged with a termination date or lifetime after 4 minutes
  • The termination_date or lifetime tags are present but cannot be parsed
  • The termination_date or lifetime tags indicate that the instance has expired

An instance may be configured to never terminate if its lifetime tag has the special value indefinite. The termination_date or lifetime labels are present but cannot be parsed.

  • The termination_date or lifetime labels indicate that the instance has expired.

An instance may be configured to never terminate if its lifetime label has the special value indefinite. Other valid values for the lifetime label are of the form <number><unit> where <number> is any integer and <unit> is a time unit of w(weeks), h(hours), d(days) or m(months). So, as an example, if the lifetime label for an instance has a value of 43w then it should be terminated after it's 43 weeks old.

Code

Relay uses YAML to define the steps in a workflow.

Graph

Each step in the workflow is visualized below.
ec2-reaper

Install the Relay CLI

Relay CLI is an essential companion for authoring and managing workflows. You can install it with a package manager or download it.
brew install puppetlabs/puppet/relay
Learn more about setting up Relay.

How to contribute

We’re excited to see and share in our community’s creation. Take a look at our community overview to learn how to begin contributing to Relay.