Sha256: 822e2314a92e02976409fbb603b4f3552472be689d5446a6e2638cff72085bef
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 KB
Contents
require_relative "adapter" require "aws-sdk-ssm" module Blinkist class Config class AwsSsmAdapter < Adapter DEFAULT_PREFIX = "/application/".freeze def initialize(env, app_name) super env, app_name @items_cache = {} @client = Aws::SSM::Client.new end def get(key, default=nil, scope: nil) prefix = prefix_for(scope) query_ssm_parameter "#{prefix}/#{key}" rescue Aws::SSM::Errors::ParameterNotFound default end def preload(scope: nil) query_all_ssm_parameters prefix_for(scope) end private def prefix_for(scope) if scope.nil? DEFAULT_PREFIX + @app_name else DEFAULT_PREFIX + scope end end def query_ssm_parameter(name) @items_cache[name] ||= @client.get_parameter( name: name, with_decryption: true ).parameter.value end def query_all_ssm_parameters(prefix) @client.get_parameters_by_path( path: prefix, recursive: true, with_decryption: true ).parameters.map do |parameter| @items_cache[parameter.name] = parameter.value end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
blinkist-config-1.2.0 | lib/blinkist/config/adapters/aws_ssm_adapter.rb |