Class: StratoEnv::SSMFetcher
- Inherits:
-
Object
- Object
- StratoEnv::SSMFetcher
- Defined in:
- lib/strato_env/ssm_fetcher.rb
Overview
SSM Parameter Store implementation of the fetcher protocol used by StratoEnv.
Given a path, returns a Hash<String, String> mapping each parameter’s basename (last path component) to its value. Pages are followed transparently and SecureString values are decrypted by default.
Instance Method Summary collapse
-
#call(path) ⇒ Hash<String, String>
Fetch all parameters under a single SSM path.
-
#initialize(client: nil, recursive: false, with_decryption: true) ⇒ SSMFetcher
constructor
A new instance of SSMFetcher.
Constructor Details
#initialize(client: nil, recursive: false, with_decryption: true) ⇒ SSMFetcher
Returns a new instance of SSMFetcher.
22 23 24 25 26 |
# File 'lib/strato_env/ssm_fetcher.rb', line 22 def initialize(client: nil, recursive: false, with_decryption: true) @client = client || Aws::SSM::Client.new @recursive = recursive @with_decryption = with_decryption end |
Instance Method Details
#call(path) ⇒ Hash<String, String>
Fetch all parameters under a single SSM path.
32 33 34 35 36 37 38 |
# File 'lib/strato_env/ssm_fetcher.rb', line 32 def call(path) @client.get_parameters_by_path( path: path, recursive: @recursive, with_decryption: @with_decryption ).each_page.flat_map(&:parameters).to_h do |param| [param.name.split("/").last, param.value] end end |