aws.rb 606 B

1234567891011121314151617181920212223242526
  1. # frozen_string_literal: true
  2. require 'accounts'
  3. require 'fog'
  4. require 'neoinfra/config'
  5. # NeoInfra Account information
  6. module NeoInfra
  7. # Provide informations about the accounts available
  8. class Aws
  9. def regions
  10. @cfg = NeoInfra::Config.new
  11. account = @cfg.accounts.first
  12. base_conf = {
  13. :provider => 'AWS',
  14. :aws_access_key_id => account[:key],
  15. :aws_secret_access_key => account[:secret]
  16. }
  17. conn = Fog::Compute.new(base_conf)
  18. conn.describe_regions.data[:body]['regionInfo'].collect{ |x| x['regionName']}
  19. end
  20. end
  21. end