class Awful::ElastiCache

Constants

COLORS

Public Instance Methods

color(string) click to toggle source
# File lib/awful/elasticache.rb, line 21
def color(string)
  set_color(string, COLORS.fetch(string.to_sym, :yellow))
end
dump(id = nil) click to toggle source
# File lib/awful/elasticache.rb, line 51
def dump(id = nil)
  elasticache.describe_cache_clusters(
    cache_cluster_id:     id,
    show_cache_node_info: options[:nodes]
  ).cache_clusters.tap do |clusters|
    clusters.each do |cluster|
      puts YAML.dump(stringify_keys(cluster.to_hash))
    end
  end
end
elasticache() click to toggle source
# File lib/awful/elasticache.rb, line 17
def elasticache
  @elasticache ||= Aws::ElastiCache::Client.new
end
endpoint(id) click to toggle source
# File lib/awful/elasticache.rb, line 65
def endpoint(id)
  elasticache.describe_cache_clusters(
    cache_cluster_id:     id,
    show_cache_node_info: true
  ).cache_clusters.first.cache_nodes.first.endpoint.tap do |ep|
    puts ep.address + ':' + ep.port.to_s
  end
end
ls(id = nil) click to toggle source
# File lib/awful/elasticache.rb, line 28
def ls(id = nil)
  elasticache.describe_cache_clusters(cache_cluster_id: id).cache_clusters.tap do |clusters|
    if options[:long]
      print_table clusters.map { |c|
        [
          c.cache_cluster_id,
          c.engine,
          c.engine_version,
          c.num_cache_nodes,
          c.cache_node_type,
          c.preferred_availability_zone,
          color(c.cache_cluster_status),
          c.cache_cluster_create_time
        ]
      }
    else
      puts clusters.map(&:cache_cluster_id)
    end
  end
end