secretsmanager

package
v0.3.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 12 Imported by: 0

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

View Source
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

View Source
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

func WithClient(client API) Option

WithClient injects a pre-built client. When set, region, credential, and endpoint options are ignored.

func WithEndpoint

func WithEndpoint(endpoint string) Option

WithEndpoint sets a custom endpoint (e.g. LocalStack).

func WithRegion

func WithRegion(region string) Option

WithRegion sets the AWS region.

func WithSecret

func WithSecret(name string) Option

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

func WithSecretAtKey(name, key string) Option

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

func WithStaticCredentials(accessKeyID, secretAccessKey string) Option

WithStaticCredentials sets static AWS credentials. When either value is empty, the default AWS credential chain is used instead.

func WithTimeout

func WithTimeout(d time.Duration) Option

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

func NewProvider(opts ...Option) *Provider

NewProvider creates a new AWS SecretsManager provider.

func (*Provider) Load

func (p *Provider) Load() (map[string]any, error)

Load implements the Provider interface using a background context bounded by the configured timeout.

func (*Provider) LoadContext

func (p *Provider) LoadContext(ctx context.Context) (map[string]any, error)

LoadContext implements the providers.ContextProvider interface.

func (*Provider) Name

func (p *Provider) Name() string

Name implements the Provider interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL