class Awful::Ssm

Constants

COLORS

Public Instance Methods

color(string) click to toggle source
# File lib/awful/ssm.rb, line 21
def color(string)
  set_color(string, COLORS.fetch(string.to_sym, :yellow))
end
documents(name = '.') click to toggle source
# File lib/awful/ssm.rb, line 59
def documents(name = '.')
  filter = [{key: 'PlatformTypes', value: options[:platform_types].capitalize}]
  ssm.list_documents(document_filter_list: filter).document_identifiers.select do |doc|
    doc.name.match(/#{name}/i)
  end.output do |docs|
    if options[:long]
      print_table docs.map { |d| [d.name, d.platform_types.join(',')] }
    else
      puts docs.map(&:name)
    end
  end
end
dump(id) click to toggle source
# File lib/awful/ssm.rb, line 48
def dump(id)
  ssm.list_command_invocations(command_id: id, details: true).command_invocations.output do |cmds|
    cmds.each do |cmd|
      puts YAML.dump(stringify_keys(cmd.to_hash))
    end
  end
end
ls() click to toggle source
# File lib/awful/ssm.rb, line 28
def ls
  ssm.list_commands.commands.output do |cmds|
    if options[:long]
      print_table cmds.map { |c|
        [
          c.command_id,
          c.instance_ids.join(','),
          c.document_name,
          color(c.status),
          c.requested_date_time,
          c.comment
        ]
      }
    else
      puts cmds.map(&:command_id)
    end
  end
end
shell_script(*instance_ids) click to toggle source
# File lib/awful/ssm.rb, line 78
def shell_script(*instance_ids)
  ssm.send_command(
    instance_ids: instance_ids,
    comment: options[:comment],
    timeout_seconds: options[:timeout],
    output_s3_bucket_name: options[:bucket],
    output_s3_key_prefix: options[:prefix],
    document_name: 'AWS-RunShellScript',
    parameters: {
      commands: options[:commands]
    }
  ).output do |response|
    puts response.command.command_id
  end
end
ssm() click to toggle source
# File lib/awful/ssm.rb, line 17
def ssm
  @ssm ||= Aws::SSM::Client.new
end