class Lakitu::Provider::Aws
Constants
- CREDENTIALS_PATH
- REGIONS
Public Instance Methods
instances(profile, region)
click to toggle source
# File lib/lakitu/providers/aws.rb, line 19 def instances profile, region result = ec2(profile, region) .instances .to_a .select { |x| x.state.name == "running" } .map { |x| to_hash x } result.each do |x| x[:profile] = profile x[:region] = region x[:provider] = 'aws' end end
profiles()
click to toggle source
# File lib/lakitu/providers/aws.rb, line 12 def profiles IniParse.parse(File.read(File.expand_path(CREDENTIALS_PATH))).to_hash.keys.reject() do |x| x == '__anonymous__' end rescue Errno::ENOENT Lakitu.logger.info "No AWS credentials file found at #{CREDENTIALS_PATH}, skipping" [] end
regions()
click to toggle source
# File lib/lakitu/providers/aws.rb, line 33 def regions REGIONS end
Private Instance Methods
ec2(profile, region)
click to toggle source
# File lib/lakitu/providers/aws.rb, line 39 def ec2 profile, region ::Aws::EC2::Resource.new(region: region, profile: profile) end
to_hash(instance)
click to toggle source
# File lib/lakitu/providers/aws.rb, line 43 def to_hash instance { id: instance.id, name: (instance.tags.select do |x| x.key == 'Name' end.first.value rescue 'blank'), key: instance.key_name, private_ip: instance.private_ip_address, public_ip: instance.public_ip_address } end