Class: KnifeAwscleaner::AwsAccounts

Inherits:
Object
  • Object
show all
Defined in:
lib/chef/knife/awscleaner.rb

Overview

AwsAccounts abstracts the AWS connection and query logic

Instance Method Summary collapse

Constructor Details

#initialize(profiles) ⇒ AwsAccounts

Returns a new instance of AwsAccounts.



125
126
127
128
129
130
131
132
133
# File 'lib/chef/knife/awscleaner.rb', line 125

def initialize(profiles)
  @accounts = []
  profiles.each do |profile|
    @accounts << Aws::EC2::Resource.new(
      region: profile[1],
      credentials: Aws::SharedCredentials.new(profile_name: profile[0])
    )
  end
end

Instance Method Details

#all_instancesObject



135
136
137
138
139
140
141
# File 'lib/chef/knife/awscleaner.rb', line 135

def all_instances
  all_instanaces = []

  @accounts.each do |acct|
    all_instanaces += acct.instances.map(&:instance_id)
  end
end