Class: Lamby::SsmParameterStore
- Inherits:
-
Object
- Object
- Lamby::SsmParameterStore
- Defined in:
- lib/lamby/ssm_parameter_store.rb
Defined Under Namespace
Classes: Param
Constant Summary collapse
- MAX_RESULTS =
10
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #client ⇒ Object
- #get! ⇒ Object
-
#initialize(path, options = {}) ⇒ SsmParameterStore
constructor
A new instance of SsmParameterStore.
- #label ⇒ Object
- #to_dotenv ⇒ Object
- #to_env(overwrite: true) ⇒ Object
Constructor Details
#initialize(path, options = {}) ⇒ SsmParameterStore
Returns a new instance of SsmParameterStore.
30 31 32 33 34 |
# File 'lib/lamby/ssm_parameter_store.rb', line 30 def initialize(path, = {}) @path = path @params = [] @options = end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
10 11 12 |
# File 'lib/lamby/ssm_parameter_store.rb', line 10 def params @params end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
10 11 12 |
# File 'lib/lamby/ssm_parameter_store.rb', line 10 def path @path end |
Class Method Details
.dotenv(path) ⇒ Object
14 15 16 |
# File 'lib/lamby/ssm_parameter_store.rb', line 14 def dotenv(path) new(path).get!.to_dotenv end |
.get!(path) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/lamby/ssm_parameter_store.rb', line 18 def get!(path) parts = path[1..-1].split('/') env = parts.pop path = "/#{parts.join('/')}" param = new(path).get!.params.detect do |p| p.env == env end param&.value end |
Instance Method Details
#client ⇒ Object
56 57 58 59 60 61 |
# File 'lib/lamby/ssm_parameter_store.rb', line 56 def client @client ||= begin = @options[:client_options] || {} Aws::SSM::Client.new() end end |
#get! ⇒ Object
46 47 48 49 50 |
# File 'lib/lamby/ssm_parameter_store.rb', line 46 def get! get_all! get_history! unless label.to_s.empty? self end |
#label ⇒ Object
52 53 54 |
# File 'lib/lamby/ssm_parameter_store.rb', line 52 def label ENV['LAMBY_SSM_PARAMS_LABEL'] || @options[:label] end |
#to_dotenv ⇒ Object
42 43 44 |
# File 'lib/lamby/ssm_parameter_store.rb', line 42 def to_dotenv File.open(dotenv_file, 'a') { |f| f.write(dotenv_contents) } end |
#to_env(overwrite: true) ⇒ Object
36 37 38 39 40 |
# File 'lib/lamby/ssm_parameter_store.rb', line 36 def to_env(overwrite: true) params.each do |param| overwrite ? ENV[param.env] = param.value : ENV[param.env] ||= param.value end end |