class AwsCleanup
Constants
- DELETE_LIMIT
- TEST_GROUP_ID
- TEST_GROUP_NAME
- TEST_INSTANCE_EXPIRE_AGE
- VERSION
Public Class Methods
run(resource)
click to toggle source
# File lib/aws-cleanup.rb, line 10 def self.run(resource) AwsCleanup.new.run resource end
Public Instance Methods
run(resource = nil)
click to toggle source
# File lib/aws-cleanup.rb, line 14 def run(resource = nil) if resource require "#{resource}-cleanup" AwsCleanup.const_get("#{resource.capitalize}Cleanup").run return end Dir.glob(File.dirname(File.absolute_path __FILE__) + '/modules/*').each do |resource_file| require resource_file class_name = "#{File.basename(resource_file).sub('.rb', '').capitalize}Cleanup" AwsCleanup.const_get(class_name).run end end
Private Instance Methods
ec2()
click to toggle source
# File lib/aws-cleanup.rb, line 41 def ec2 @ec2 ||= Aws::EC2::Client.new end
instance_ids()
click to toggle source
# File lib/aws-cleanup.rb, line 30 def instance_ids instances.map(&:instance_id) end
instances()
click to toggle source
# File lib/aws-cleanup.rb, line 34 def instances @instances ||= ec2.describe_instances( filters: [{ name: 'instance-state-name', values: ['running'] }] ).reservations.map(&:instances).flatten end