Class: KubesAws::SSM::Fetcher

Inherits:
Object
  • Object
show all
Includes:
Logging, KubesAws::Services
Defined in:
lib/kubes_aws/ssm/fetcher.rb

Instance Method Summary collapse

Methods included from KubesAws::Services

#eks, #iam, #secrets, #ssm

Methods included from Logging

#logger

Constructor Details

#initialize(options = {}) ⇒ Fetcher

Returns a new instance of Fetcher.



6
7
8
9
# File 'lib/kubes_aws/ssm/fetcher.rb', line 6

def initialize(options={})
  @options = options
  @base64 = options[:base64].nil? ? true : options[:base64]
end

Instance Method Details

#fetch(name) ⇒ Object



11
12
13
14
15
# File 'lib/kubes_aws/ssm/fetcher.rb', line 11

def fetch(name)
  value = fetch_value(name)
  value = Base64.strict_encode64(value).strip if @base64
  value
end

#fetch_value(name) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/kubes_aws/ssm/fetcher.rb', line 17

def fetch_value(name)
  resp = ssm.get_parameter(name: name, with_decryption: true)
  resp.parameter.value
rescue Aws::SSM::Errors::ParameterNotFound => e
  logger.info "WARN: name #{name} not found".color(:yellow)
  logger.info e.message
  "NOT FOUND #{name}" # simple string so Kubernetes YAML is valid
end