class ChiliLogger::Values::Secrets::AwsSecretsManager
Module to load secrets environment variables
Public Class Methods
new(region_name = 'us-east-1')
click to toggle source
# File lib/helpers/values/secrets/aws_secrets_manager.rb, line 12 def initialize(region_name = 'us-east-1') @client = Aws::SecretsManager::Client.new(region: region_name) end
Public Instance Methods
get_secrets_collection(collection_name)
click to toggle source
# File lib/helpers/values/secrets/aws_secrets_manager.rb, line 16 def get_secrets_collection(collection_name) JSON.parse(get_secret(collection_name)) end
Private Instance Methods
get_secret(secret_name)
click to toggle source
Use this code snippet in your app. If you need more information about configurations or implementing the sample code, visit the AWS
docs: aws.amazon.com/developers/getting-started/ruby/ method from AWS
example, ipsis literis
# File lib/helpers/values/secrets/aws_secrets_manager.rb, line 26 def get_secret(secret_name) # In this sample we only handle the specific exceptions for the 'GetSecretValue' API. # See https://docs.aws.amazon.com/secretsmanager/latest/apireference/API_GetSecretValue.html # We rethrow the exception by default. get_secret_value_response = @client.get_secret_value(secret_id: secret_name) # Decrypts secret using the associated KMS CMK. # Depending on whether the secret is a string or binary, one of these fields will be populated. get_secret_value_response.secret_string || Base64.decode64(get_secret_value_response.secret_binary) end