Class: Chambermaid::ParameterStore

Inherits:
Object
  • Object
show all
Defined in:
lib/chambermaid/parameter_store.rb

Overview

Note:

AWS authentication requires configuration via ENV (IAM credentials/STS)

ParameterStore instances fetch all parameters under a namespace/path from AWS SSM

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:) ⇒ ParameterStore

Returns a new instance of ParameterStore.

Parameters:

  • path (String)


10
11
12
# File 'lib/chambermaid/parameter_store.rb', line 10

def initialize(path:)
  @path = path
end

Class Method Details

.load!(path:) ⇒ Chambermaid::ParameterStore

Create a ParameterStore and fetch from AWS SSM immediately

Returns:

See Also:



41
42
43
44
45
# File 'lib/chambermaid/parameter_store.rb', line 41

def self.load!(path:)
  store = new(path: path)
  store.load!
  store
end

Instance Method Details

#load!Boolean

Fetch and decrypt all parameters selected by a namespace/path string

Returns:

  • (Boolean)


17
18
19
# File 'lib/chambermaid/parameter_store.rb', line 17

def load!
  fetch_ssm_params!
end

#loaded?Boolean

Returns true if parameters have been fetched from AWS SSM

Returns:

  • (Boolean)


32
33
34
# File 'lib/chambermaid/parameter_store.rb', line 32

def loaded?
  !@params_list.empty?
end

#paramsHash Also known as: to_h

ENV formatted Hash of parameters loaded from AWS SSM

Returns:

  • (Hash)


50
51
52
53
54
# File 'lib/chambermaid/parameter_store.rb', line 50

def params
  @params ||= @param_list.map { |p|
    [p.name.split("/").last.upcase, p.value]
  }.to_h
end

#reload!Boolean

Clear cached parameters and re-fetch parameters from AWS SSM

Returns:

  • (Boolean)


24
25
26
27
# File 'lib/chambermaid/parameter_store.rb', line 24

def reload!
  clear_params!
  fetch_ssm_params!
end