Documentation
¶
Overview ¶
Package awssm implements secrets.SecretProvider using AWS Secrets Manager. It wraps github.com/aws/aws-sdk-go-v2/service/secretsmanager.
AWS SM URIs take the form
aws-sm://<name-or-prefix>[/<path>][#<field>]
where <name-or-prefix> is the first segment of the secret name (the URI host), <path> is the rest of the name joined with "/", and the optional <field> selects one key from a JSON-valued secret.
Auth uses the standard AWS SDK default credential chain: env vars, shared credentials file, IRSA, ECS task role, or EC2 instance profile. No explicit credentials in config.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
secrets.ProviderConfigMarker
// Region is the AWS region to use (e.g. "us-east-1"). Required.
Region string
}
Config configures the AWS Secrets Manager provider.
Config satisfies secrets.ProviderConfig by embedding secrets.ProviderConfigMarker.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider is an AWS Secrets Manager-backed secrets.SecretProvider.
Provider is safe for concurrent Fetch and Close. Close waits for any in-flight Fetch to finish before returning, so the contract "after Close returns, Fetch returns an error" holds even under concurrent access.
Concurrency design mirrors keyring.Provider and vault.Provider:
- closed is an atomic flag checked lock-free on the Fetch fast path.
- mu is an RWMutex held for read by Fetch for its entire duration (including the AWS HTTP call) and for write by Close. The write lock ensures Close waits for any in-flight Fetch to finish before returning.
func New ¶
New constructs an AWS Secrets Manager provider.
Steps:
- Validate the config (region required).
- Load default AWS config with the specified region.
- Create the Secrets Manager client.
- Probe connectivity via STS GetCallerIdentity.
func (*Provider) Close ¶
Close marks the provider as closed. Safe to call concurrently and multiple times — subsequent calls are no-ops.
func (*Provider) Fetch ¶
Fetch retrieves a secret from AWS Secrets Manager.
The SecretRef must have:
- Scheme == "aws-sm"
- Host (the secret name or first path segment)
- Path (optional additional path segments, joined with "/")
- Field (optional) selects one key from a JSON-valued secret
If Field is empty and the value is a JSON object with exactly one key, the single value is auto-resolved. If the value is not JSON or has multiple keys, it is returned as-is (plain string).