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 ¶
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 (*Provider) ClearCache ¶
func (p *Provider) ClearCache()
func (*Provider) Get ¶
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.
}
Output: