class Interferon::HostSources::AwsDynamo

Public Class Methods

new(options) click to toggle source
# File lib/interferon/host_sources/aws_dynamo.rb, line 5
def initialize(options)
  missing = %w(access_key_id secret_access_key).reject { |r| options.key?(r) }

  AWS.config(access_key_id: options['access_key_id'],
             secret_access_key: options['secret_access_key']) if missing.empty?

  # initialize a list of regions to check
  @regions = if options['regions'] && !options['regions'].empty?
               options['regions']
             else
               AWS.regions.map(&:name)
             end
end

Public Instance Methods

list_hosts() click to toggle source
# File lib/interferon/host_sources/aws_dynamo.rb, line 19
def list_hosts
  hosts = []

  @regions.each do |region|
    client = AWS::DynamoDB.new(region: region)

    AWS.memoize do
      client.tables.each do |table|
        hosts << {
          source: 'aws_dynamo',
          region: region,
          table_name: table.name,

          read_capacity: table.read_capacity_units,
          write_capacity: table.write_capacity_units,

          # dynamodb does not support tagging
          owners: [],
          owner_groups: [],
        }
      end
    end
  end

  hosts
end