Class: Chambermaid::ParameterStore
- Inherits:
-
Object
- Object
- Chambermaid::ParameterStore
- Defined in:
- lib/chambermaid/parameter_store.rb
Overview
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
-
.load!(path:) ⇒ Chambermaid::ParameterStore
Create a ParameterStore and fetch from AWS SSM immediately.
Instance Method Summary collapse
-
#initialize(path:) ⇒ ParameterStore
constructor
A new instance of ParameterStore.
-
#load! ⇒ Boolean
Fetch and decrypt all parameters selected by a namespace/path string.
-
#loaded? ⇒ Boolean
Returns true if parameters have been fetched from AWS SSM.
-
#params ⇒ Hash
(also: #to_h)
ENV formatted Hash of parameters loaded from AWS SSM.
-
#reload! ⇒ Boolean
Clear cached parameters and re-fetch parameters from AWS SSM.
Constructor Details
#initialize(path:) ⇒ ParameterStore
Returns a new instance of ParameterStore.
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
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
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
32 33 34 |
# File 'lib/chambermaid/parameter_store.rb', line 32 def loaded? !@params_list.empty? end |
#params ⇒ Hash Also known as: to_h
ENV formatted Hash of parameters loaded from AWS SSM
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
24 25 26 27 |
# File 'lib/chambermaid/parameter_store.rb', line 24 def reload! clear_params! fetch_ssm_params! end |