awssm

package
v0.0.0-...-230ac96 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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.

func (Config) TypeName

func (Config) TypeName() string

TypeName returns "aws-sm". Used by the registry to map aws-sm:// URI scheme refs to this provider.

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

func New(ctx context.Context, cfg Config, _ secrets.RefResolver) (*Provider, error)

New constructs an AWS Secrets Manager provider.

Steps:

  1. Validate the config (region required).
  2. Load default AWS config with the specified region.
  3. Create the Secrets Manager client.
  4. Probe connectivity via STS GetCallerIdentity.

func (*Provider) Close

func (p *Provider) Close() error

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).

func (*Provider) Name

func (p *Provider) Name() string

Name returns "aws-sm". Used in audit events.

Jump to

Keyboard shortcuts

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