secrets

package
v1.0.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package secrets retrieves AWS Secrets Manager values with local caching.

New wraps an application-owned AWS SDK v2 Client. Provider.Get supports string and binary secrets; GetOptions combines SDK selectors with Parameters cache and transform options. Pass invocation context to retrieval calls.

Cache and ownership

Effective version ID and stage selectors isolate entries. Forced refresh and nonpositive age follow the shared Parameters policy. Provider.ClearCache invalidates the local cache. Package-level helpers initialize their default provider lazily; explicit providers allow custom clients and endpoints.

Treat retrieved values as sensitive application data and avoid logging them.

For usage and compatibility details, see the user guide.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSecret

func GetSecret(ctx context.Context, name string, options GetOptions) (any, error)

Types

type Client

type Client interface {
	GetSecretValue(context.Context, *sdk.GetSecretValueInput, ...func(*sdk.Options)) (*sdk.GetSecretValueOutput, error)
}

type GetOptions

type GetOptions struct {
	parameters.Options
	SDKOptions *sdk.GetSecretValueInput
}

type Provider

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

func New

func New(client Client) *Provider

func (*Provider) ClearCache

func (p *Provider) ClearCache()

func (*Provider) Get

func (p *Provider) Get(ctx context.Context, name string, options GetOptions) (any, error)
Example

This example requires AWS credentials and an existing Secrets Manager secret.

package main

import (
	"context"

	"github.com/aws/aws-sdk-go-v2/config"
	sdk "github.com/aws/aws-sdk-go-v2/service/secretsmanager"
	"github.com/rambow-cloud/powertools-lambda-go/parameters/secrets"
)

func main() {
	ctx := context.Background()
	cfg, err := config.LoadDefaultConfig(ctx)
	if err != nil {
		panic(err)
	}
	provider := secrets.New(sdk.NewFromConfig(cfg))
	value, err := provider.Get(ctx, "example/secret", secrets.GetOptions{})
	if err != nil {
		panic(err)
	}
	_ = value // Consume the secret without logging it.
}

Jump to

Keyboard shortcuts

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