Class: Awry::Ssm

Inherits:
Cli
  • Object
show all
Defined in:
lib/awry/ssm.rb

Instance Method Summary collapse

Instance Method Details

#delete(name) ⇒ Object



47
48
49
50
51
52
53
# File 'lib/awry/ssm.rb', line 47

def delete(name)
  if yes?("Really delete parameter #{name}?", :yellow)
    client.delete_parameter(name: name)
  end
rescue Aws::SSM::Errors::ParameterNotFound => e
  error(e.message)
end

#get(name) ⇒ Object



22
23
24
25
26
# File 'lib/awry/ssm.rb', line 22

def get(name)
  puts client.get_parameter(name: name, with_decryption: options[:decrypt]).parameter.value
rescue Aws::SSM::Errors::ParameterNotFound => e
  error(e.message)
end

#ls(prefix = '/') ⇒ Object



12
13
14
15
16
17
18
# File 'lib/awry/ssm.rb', line 12

def ls(prefix = '/')
  filters = [ { key: :Name, option: :BeginsWith, values: [ prefix.sub(/^(\w)/, '/\1') ] } ]
  client.describe_parameters(parameter_filters: filters).each do |response|
    response.parameters.each { |p| puts p.name }
    sleep 0.1               # this api will throttle easily
  end
end

#put(name, value) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/awry/ssm.rb', line 33

def put(name, value)
  client.put_parameter(
    name:        name,
    value:       value,
    description: options[:description],
    type:        options[:type],
    key_id:      options[:key_id],
    overwrite:   options[:overwrite],
  )
rescue Aws::SSM::Errors::ParameterAlreadyExists => e
  error(e.message)
end