Documentation
¶
Overview ¶
Package secretsmanager provides a gas-config provider that loads configuration from AWS Secrets Manager. Secrets are registered explicitly and fetched eagerly when the configuration is loaded.
Index ¶
- Constants
- Variables
- type API
- type Option
- func WithClient(client API) Option
- func WithEndpoint(endpoint string) Option
- func WithRegion(region string) Option
- func WithSecret(name string) Option
- func WithSecretAtKey(name, key string) Option
- func WithStaticCredentials(accessKeyID, secretAccessKey string) Option
- func WithTimeout(d time.Duration) Option
- type Provider
Constants ¶
const ( // ProviderName is the name reported by Name. ProviderName = "AWS SecretsManager" // DefaultTimeout bounds Load when no caller context is supplied. DefaultTimeout = 10 * time.Second )
Variables ¶
var ( // ErrNoSecretsConfigured indicates that Load was called without any registered secrets. ErrNoSecretsConfigured = errors.New("no secrets configured") // ErrSecretFetchFailed indicates a failure to fetch a secret from AWS SecretsManager. ErrSecretFetchFailed = errors.New("failed to fetch secret") // ErrSecretDecodeFailed indicates that a secret value could not be decoded. ErrSecretDecodeFailed = errors.New("failed to decode secret") // ErrClientInitFailed indicates a failure to initialize the SecretsManager client. ErrClientInitFailed = errors.New("failed to initialize SecretsManager client") )
Functions ¶
This section is empty.
Types ¶
type API ¶
type API interface {
GetSecretValue(ctx context.Context, params *awssm.GetSecretValueInput, optFns ...func(*awssm.Options)) (*awssm.GetSecretValueOutput, error)
}
API is the subset of the AWS SecretsManager client used by the provider. *secretsmanager.Client satisfies it; tests may inject a mock via WithClient.
type Option ¶
type Option func(*Provider)
Option is a function that configures a Provider.
func WithClient ¶
WithClient injects a pre-built client. When set, region, credential, and endpoint options are ignored.
func WithEndpoint ¶
WithEndpoint sets a custom endpoint (e.g. LocalStack).
func WithSecret ¶
WithSecret registers a secret (name or full ARN) whose value must decode to a JSON object. The object is deep-merged into the configuration at the root. Repeatable; later registrations win on key conflicts.
func WithSecretAtKey ¶
WithSecretAtKey registers a secret placed at the dot-notation key. A JSON object value is nested at that path; any other value is placed at the path as a raw string. An empty key behaves like WithSecret.
func WithStaticCredentials ¶
WithStaticCredentials sets static AWS credentials. When either value is empty, the default AWS credential chain is used instead.
func WithTimeout ¶
WithTimeout bounds Load when no caller context is supplied.
Default: DefaultTimeout.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider loads configuration from AWS Secrets Manager.
func NewProvider ¶
NewProvider creates a new AWS SecretsManager provider.
func (*Provider) Load ¶
Load implements the Provider interface using a background context bounded by the configured timeout.
func (*Provider) LoadContext ¶
LoadContext implements the providers.ContextProvider interface.