Class: InstancesCleanup

Inherits:
AwsCleanup show all
Defined in:
lib/modules/instances.rb

Constant Summary

Constants inherited from AwsCleanup

AwsCleanup::DELETE_LIMIT, AwsCleanup::TEST_GROUP_ID, AwsCleanup::TEST_GROUP_NAME, AwsCleanup::TEST_INSTANCE_EXPIRE_AGE, AwsCleanup::VERSION

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AwsCleanup

#run

Class Method Details

.runObject



2
3
4
# File 'lib/modules/instances.rb', line 2

def self.run
  InstancesCleanup.new.cleanup_instances
end

Instance Method Details

#cleanup_instancesObject



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/modules/instances.rb', line 6

def cleanup_instances
  eii = expired_instances_ids
  if eii.any?
    prompt_user eii if eii.count > DELETE_LIMIT
    puts 'Deleting instances: ' + eii.join(', ')
    ec2.terminate_instances instance_ids: eii
    return
  end

  puts 'No instances to clean up'
end