Documentation
¶
Overview ¶
Package ssm retrieves and writes AWS Systems Manager Parameter Store values.
New wraps an application-owned AWS SDK v2 Client. Provider.Get retrieves one parameter, Provider.GetMultiple traverses a path, and Provider.Set writes a parameter. GetOptions and MultipleOptions select SDK request options and the shared Parameters cache/transform policy.
Defaults and isolation ¶
Package-level helpers lazily initialize a default provider; use an explicit provider when controlling clients, endpoints or credentials. Effective decrypt and path request options isolate cached values, and matching single/batch reads can reuse entries. Provider.ClearCache invalidates local cached configuration. SDK errors retain their error chain through the Parameters error types.
For usage and compatibility details, see the user guide.
Index ¶
- func GetParameter(ctx context.Context, name string, options GetOptions) (any, error)
- func GetParameters(ctx context.Context, path string, options MultipleOptions) (map[string]any, error)
- func GetParametersByName(ctx context.Context, names map[string]GetOptions, options ByNameOptions) (map[string]any, error)
- func SetParameter(ctx context.Context, name, value string, options *sdk.PutParameterInput) (int64, error)
- type ByNameOptions
- type Client
- type GetOptions
- type MultipleOptions
- type Provider
- func (p *Provider) ClearCache()
- func (p *Provider) Get(ctx context.Context, name string, options GetOptions) (any, error)
- func (p *Provider) GetMultiple(ctx context.Context, path string, options MultipleOptions) (map[string]any, error)
- func (p *Provider) GetParametersByName(ctx context.Context, names map[string]GetOptions, options ByNameOptions) (map[string]any, error)
- func (p *Provider) Set(ctx context.Context, name, value string, options *sdk.PutParameterInput) (int64, error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetParameter ¶
func GetParameters ¶
func GetParametersByName ¶
func GetParametersByName(ctx context.Context, names map[string]GetOptions, options ByNameOptions) (map[string]any, error)
func SetParameter ¶
Types ¶
type ByNameOptions ¶
type ByNameOptions struct {
parameters.Options
Decrypt *bool
// ThrowOnError defaults to true; false returns failed names under _errors.
ThrowOnError *bool
}
type Client ¶
type Client interface {
GetParameter(context.Context, *sdk.GetParameterInput, ...func(*sdk.Options)) (*sdk.GetParameterOutput, error)
GetParameters(context.Context, *sdk.GetParametersInput, ...func(*sdk.Options)) (*sdk.GetParametersOutput, error)
GetParametersByPath(context.Context, *sdk.GetParametersByPathInput, ...func(*sdk.Options)) (*sdk.GetParametersByPathOutput, error)
PutParameter(context.Context, *sdk.PutParameterInput, ...func(*sdk.Options)) (*sdk.PutParameterOutput, error)
}
type GetOptions ¶
type GetOptions struct {
parameters.Options
Decrypt *bool
SDKOptions *sdk.GetParameterInput
}
type MultipleOptions ¶
type MultipleOptions struct {
parameters.Options
Decrypt *bool
Recursive *bool
SDKOptions *sdk.GetParametersByPathInput
}
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 Parameter Store value.
package main
import (
"context"
"github.com/aws/aws-sdk-go-v2/config"
sdk "github.com/aws/aws-sdk-go-v2/service/ssm"
"github.com/rambow-cloud/powertools-lambda-go/parameters/ssm"
)
func main() {
ctx := context.Background()
cfg, err := config.LoadDefaultConfig(ctx)
if err != nil {
panic(err)
}
provider := ssm.New(sdk.NewFromConfig(cfg))
value, err := provider.Get(ctx, "/example/feature", ssm.GetOptions{})
if err != nil {
panic(err)
}
_ = value // Reuse the provider across invocations to retain cached values.
}
Output:
func (*Provider) GetMultiple ¶
func (*Provider) GetParametersByName ¶
func (p *Provider) GetParametersByName(ctx context.Context, names map[string]GetOptions, options ByNameOptions) (map[string]any, error)
GetParametersByName supports per-name overrides, groups decryption requirements, and fetches at most ten names per batch. Input maps are never modified.