require "meroku/infrastructure/node" module Meroku module Infrastructure extend Meroku::Aws def self.despawn instances = ec2_client.describe_instances(filters:[{ name: "tag:Name", values: ['node'] }, { name: 'instance-state-name', values: ['running','pending'] }]).reservations.map { |xx| xx.instances.first.instance_id } puts "will despawn #{instances.inspect}" ec2_client.terminate_instances({ instance_ids: instances }) if instances.size > 0 end end end