aws.rb 579 B

123456789101112131415161718192021222324
  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