Module: AwsSecretsManager::GetSecretValue

Includes:
KeyValue, Plaintext
Included in:
AwsSecretsManager
Defined in:
lib/aws_secrets_manager/get_secret_value.rb

Instance Method Summary collapse

Instance Method Details

#get_secret_value(secrets) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/aws_secrets_manager/get_secret_value.rb', line 8

def get_secret_value(secrets)
  validator = Validator::Validate.new.call(secrets)

  raise Errors.validation_error(validator.errors.to_h) if validator.errors.any?

  secrets[:secrets].each do |secret|
    case secret[:type]
    when Config::PLAINTEXT
      then plaintext(name: secret[:name])
    when Config::KEY_VALUE
      then key_value(name: secret[:name])
    else
      raise Errors.secret_type_error
    end
  end
end