class Stax::Cmd::Ssm

Constants

COLORS

Public Instance Methods

commands() click to toggle source
# File lib/stax/mixin/ssm.rb, line 81
def commands
  print_table Aws::Ssm.commands.map { |c|
    [
      c.command_id,
      c.document_name,
      color(c.status, COLORS),
      c.requested_date_time,
      c.comment
    ]
  }
end
delete(*names) click to toggle source
# File lib/stax/mixin/ssm.rb, line 130
def delete(*names)
  puts my.ssm_parameter_delete(*names)
end
get(name) click to toggle source
# File lib/stax/mixin/ssm.rb, line 115
def get(name)
  puts my.ssm_parameter_get(name)
end
instances() click to toggle source
# File lib/stax/mixin/ssm.rb, line 68
def instances
  print_table Aws::Ssm.instances(my.stack_name).map { |i|
    agent = set_color(i.agent_version, i.is_latest_version ? :green : :yellow)
    [i.instance_id, color(i.ping_status, COLORS), i.last_ping_date_time, agent]
  }
end
invocation(id = nil) click to toggle source
# File lib/stax/mixin/ssm.rb, line 94
def invocation(id = nil)
  id ||= Aws::Ssm.commands.first.command_id
  Aws::Ssm.invocation(id).each do |i|
    puts YAML.dump(stringify_keys(i.to_hash))
  end
end
parameters(path = my.ssm_parameter_path) click to toggle source
# File lib/stax/mixin/ssm.rb, line 104
def parameters(path = my.ssm_parameter_path)
  fields = %i[name type]
  fields << :value if options[:decrypt]
  print_table Aws::Ssm.parameters(
    path: path,
    with_decryption: options[:decrypt],
    recursive: options[:recurse],
  ).map { |p| fields.map{ |f| p.send(f) } }
end
put(name, value) click to toggle source
# File lib/stax/mixin/ssm.rb, line 123
def put(name, value)
  my.ssm_parameter_put(name, value, type: options[:type], key_id: options[:key], overwrite: options[:overwrite])
rescue ::Aws::SSM::Errors::ParameterAlreadyExists => e
  warn(e.message)
end
shellscript(*cmd) click to toggle source
# File lib/stax/mixin/ssm.rb, line 76
def shellscript(*cmd)
  my.ssm_run_shellscript(*cmd)
end