Class: TerraspacePluginAws::Interfaces::Helper::SSM

Inherits:
SecretBase
  • Object
show all
Extended by:
Memoist
Includes:
Terraspace::Compiler::Dsl::Syntax::Mod::Backend
Defined in:
lib/terraspace_plugin_aws/interfaces/helper/ssm.rb

Instance Method Summary collapse

Methods inherited from SecretBase

#initialize

Methods included from Logging

#logger

Methods included from Clients

#dynamodb, #s3, #secretsmanager, #ssm, #sts

Constructor Details

This class inherits a constructor from TerraspacePluginAws::Interfaces::Helper::SecretBase

Instance Method Details

#fetch(name) ⇒ Object



6
7
8
9
10
11
# File 'lib/terraspace_plugin_aws/interfaces/helper/ssm.rb', line 6

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

#fetch_value(name) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/terraspace_plugin_aws/interfaces/helper/ssm.rb', line 13

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 tfvars valid
rescue Aws::SSM::Errors::ValidationException => e
  logger.info "WARN: name #{name} not found".color(:yellow)
  logger.info e.message
  "INVALID NAME #{name}" # simple string so tfvars valid
end