Class: ParamStore::Adapters::SSM

Inherits:
Object
  • Object
show all
Defined in:
lib/param_store/adapters/ssm.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(default_path: nil) ⇒ SSM

Returns a new instance of SSM.



6
7
8
# File 'lib/param_store/adapters/ssm.rb', line 6

def initialize(default_path: nil)
  @default_path = default_path
end

Instance Attribute Details

#default_pathObject (readonly)

Returns the value of attribute default_path.



4
5
6
# File 'lib/param_store/adapters/ssm.rb', line 4

def default_path
  @default_path
end

Instance Method Details

#fetch(key, *args, path: nil, &block) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/param_store/adapters/ssm.rb', line 10

def fetch(key, *args, path: nil, &block)
  key = prepend_path(path, key)
  tmp = {}
  if string = get_parameter(key)
    tmp[key] = string
  end
  tmp.fetch(key, *args, &block)
end

#fetch_all(*keys, path: nil) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/param_store/adapters/ssm.rb', line 19

def fetch_all(*keys, path: nil)
  keys = keys.flatten
  keys = keys.map { |key| prepend_path(path, key) } if path
  ParamStore.ssm_client.get_parameters(names: keys, with_decryption: true).parameters.each_with_object({}) do |param, result|
    result[param.name.gsub(path.to_s, '')] = param.value
  end
end