ExCredstash.Config (ExCredstash v0.1.1)
View SourceConfiguration handling for ExCredstash.
This module manages configuration options for the credential store, including AWS settings, table names, and encryption contexts.
Configuration Priority
Configuration values are resolved in the following order (highest to lowest priority):
- Options passed directly to functions
- Application environment (
config.exs) - Environment variables
- Default values
Application Environment
config :ex_credstash,
table: "credential-store",
kms_key: "alias/credstash",
region: "us-east-1"Environment Variables
CREDSTASH_DEFAULT_TABLE- DynamoDB table nameCREDSTASH_KEY_ID- KMS key ID or aliasAWS_DEFAULT_REGIONorAWS_REGION- AWS region
Summary
Functions
Gets the encryption context from configuration.
Returns the default digest algorithm constant.
Returns the default KMS key constant.
Returns the default table name constant.
Gets the digest algorithm from configuration.
Get a configuration value, checking options first, then app config, then env vars.
Gets the KMS key ID from configuration.
Gets the AWS region from configuration.
Gets the DynamoDB table name from configuration.
Functions
Gets the encryption context from configuration.
Parameters
opts- Keyword list of options
Returns
The encryption context map (defaults to empty map).
Examples
iex> ExCredstash.Config.context()
%{}
iex> ExCredstash.Config.context(context: %{"env" => "prod"})
%{"env" => "prod"}
@spec default_digest() :: atom()
Returns the default digest algorithm constant.
@spec default_kms_key() :: String.t()
Returns the default KMS key constant.
@spec default_table() :: String.t()
Returns the default table name constant.
Gets the digest algorithm from configuration.
Parameters
opts- Keyword list of options
Returns
The digest algorithm atom (defaults to :sha256).
Examples
iex> ExCredstash.Config.digest()
:sha256
iex> ExCredstash.Config.digest(digest: :sha512)
:sha512
Get a configuration value, checking options first, then app config, then env vars.
Priority: opts > app config > env vars > default
Parameters
opts- Keyword list of optionskey- Configuration key to look updefault- Default value if not found (default: nil)
Examples
iex> ExCredstash.Config.get([table: "my-table"], :table)
"my-table"
iex> ExCredstash.Config.get([], :table, "credential-store")
"credential-store"
Gets the KMS key ID from configuration.
Parameters
opts- Keyword list of options
Returns
The KMS key ID or alias (defaults to "alias/credstash").
Examples
iex> ExCredstash.Config.kms_key()
"alias/credstash"
iex> ExCredstash.Config.kms_key(kms_key: "alias/my-key")
"alias/my-key"
Gets the AWS region from configuration.
Checks in order: opts[:region] > app config > AWS_DEFAULT_REGION > AWS_REGION
Parameters
opts- Keyword list of options
Returns
The region string or nil if not configured.
Examples
iex> ExCredstash.Config.region(region: "eu-west-1")
"eu-west-1"
Gets the DynamoDB table name from configuration.
Parameters
opts- Keyword list of options
Returns
The table name (defaults to "credential-store").
Examples
iex> ExCredstash.Config.table()
"credential-store"
iex> ExCredstash.Config.table(table: "my-creds")
"my-creds"