class AwsSecretsLoader::AwsFetcher

Public Class Methods

load() click to toggle source
# File lib/aws_secrets_loader/aws_fetcher.rb, line 9
def load
  secrets = fetch_secrets
  add_to_environment(secrets)
end

Private Class Methods

add_to_environment(secrets) click to toggle source
# File lib/aws_secrets_loader/aws_fetcher.rb, line 23
def add_to_environment(secrets)
  secrets.each do |key, value|
    ENV[key] = value
  end
end
fetch_secrets() click to toggle source
# File lib/aws_secrets_loader/aws_fetcher.rb, line 16
def fetch_secrets
  client = Aws::SecretsManager::Client.new
  get_secret_value_response = client.get_secret_value(secret_id: secret_name)

  JSON.parse(get_secret_value_response.secret_string)
end
secret_name() click to toggle source
# File lib/aws_secrets_loader/aws_fetcher.rb, line 29
def secret_name
  ENV['AWS_SECRET_NAME']
end