secretsmanager

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package secretsmanager is doze-aws's local AWS Secrets Manager: secrets with version stages (AWSCURRENT/AWSPREVIOUS plus custom labels), deletion with a recovery window, tags, and resource-policy round-trips. Secret values are genuinely encrypted at rest with a per-data-dir AES-256-GCM key the service manages itself (a KMS KeyId is recorded and returned cosmetically).

Rotation (RotateSecret) drives the four-step protocol against a configured rotation Lambda via peers. Cross-region replication is physically meaningless locally and answers honestly.

See docs/api-support/secretsmanager.md for the support table.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// DataDir holds the bbolt store (secretsmanager.bolt) and the value
	// encryption key (secretsmanager.key). Required.
	DataDir string
	// Peers lets RotateSecret invoke the configured rotation lambda.
	Peers peers.Directory
	// Logf receives log lines; nil discards.
	Logf func(format string, args ...any)
	// Clock overrides time.Now in tests.
	Clock func() time.Time
}

Options configures the service.

type Secret

type Secret struct {
	ARN         string             `json:"arn"`
	Name        string             `json:"name"`
	Description string             `json:"description,omitempty"`
	KMSKeyID    string             `json:"kms_key_id,omitempty"`
	Tags        map[string]string  `json:"tags,omitempty"`
	Policy      string             `json:"policy,omitempty"` // resource policy round-trip
	Versions    map[string]Version `json:"versions"`
	Created     int64              `json:"created"`
	LastChanged int64              `json:"last_changed"`

	RotationEnabled   bool   `json:"rotation_enabled,omitempty"`
	RotationLambdaARN string `json:"rotation_lambda_arn,omitempty"`
	LastRotatedDate   int64  `json:"last_rotated_date,omitempty"`
	DeletedAt         int64  `json:"deleted_at,omitempty"` // scheduled-deletion time set
	PurgeAt           int64  `json:"purge_at,omitempty"`   // when the janitor removes it
}

Secret is one secret with its version map.

func (*Secret) Resolve

func (sec *Secret) Resolve(versionID, stage string) (string, *Version, *awshttp.APIError)

Resolve picks a version by id or stage (default AWSCURRENT).

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is the Secrets Manager service: an http.Handler speaking AWS JSON 1.1, and an io.Closer that stops the janitor and closes the store.

func New

func New(opts Options) (*Server, error)

New opens the store under DataDir and starts the deletion janitor.

func (*Server) Close

func (s *Server) Close() error

Close stops the janitor and closes the bbolt DB.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is the bbolt-backed secret store plus the value sealer.

func (*Store) AddVersion

func (s *Store) AddVersion(id, token string, str, bin []byte, stages []string) (*Secret, string, error)

AddVersion appends a version and moves AWSCURRENT (old current becomes AWSPREVIOUS), returning the new version id.

func (*Store) Create

func (s *Store) Create(name, description, kmsKeyID, token string, str, bin []byte, tags map[string]string) (*Secret, string, error)

Create makes a new secret with an initial version, or fails if it exists.

func (*Store) Delete

func (s *Store) Delete(id string, recoveryDays int, force bool) (*Secret, error)

Delete schedules (or forces) deletion.

func (*Store) Get

func (s *Store) Get(id string) (*Secret, error)

Get loads a secret by name or ARN.

func (*Store) List

func (s *Store) List() ([]Secret, error)

List returns all secrets, sorted by name.

func (*Store) Mutate

func (s *Store) Mutate(id string, fn func(*Secret) error) (*Secret, error)

Mutate applies fn to a secret and persists it.

func (*Store) Restore

func (s *Store) Restore(id string) (*Secret, error)

Restore cancels a scheduled deletion.

func (*Store) SweepDeleted

func (s *Store) SweepDeleted()

SweepDeleted purges secrets whose recovery window has passed.

type Version

type Version struct {
	String  []byte   `json:"string,omitempty"` // sealed
	Binary  []byte   `json:"binary,omitempty"` // sealed
	Stages  []string `json:"stages,omitempty"`
	Created int64    `json:"created"`
}

Version is one secret version. Exactly one of String/Binary was set by the caller; both are sealed at rest.

Jump to

Keyboard shortcuts

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