Documentation
¶
Overview ¶
Package dynamodb retrieves configuration values from an AWS DynamoDB table.
New wraps an application-owned AWS SDK v2 Client using Config for the table and attribute names. Provider.Get retrieves one value and Provider.GetMultiple queries a configuration path, including paginated results. Their option types combine SDK requests with Parameters cache and transforms.
Table and cache policy ¶
The application provisions the table, keys and permissions. This adapter does not create tables. Successful retrievals are cached according to Parameters policy; Provider.ClearCache invalidates local entries. Missing-value and transform behavior are explicit options, and errors retain SDK error chains.
For usage and compatibility details, see the user guide.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
GetItem(context.Context, *sdk.GetItemInput, ...func(*sdk.Options)) (*sdk.GetItemOutput, error)
Query(context.Context, *sdk.QueryInput, ...func(*sdk.Options)) (*sdk.QueryOutput, error)
}
type GetOptions ¶
type GetOptions struct {
parameters.Options
SDKOptions *sdk.GetItemInput
}
type MultipleOptions ¶
type MultipleOptions struct {
parameters.Options
SDKOptions *sdk.QueryInput
}
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 a configuration table with data.
package main
import (
"context"
"github.com/aws/aws-sdk-go-v2/config"
sdk "github.com/aws/aws-sdk-go-v2/service/dynamodb"
"github.com/rambow-cloud/powertools-lambda-go/parameters/dynamodb"
)
func main() {
ctx := context.Background()
cfg, err := config.LoadDefaultConfig(ctx)
if err != nil {
panic(err)
}
provider, err := dynamodb.New(sdk.NewFromConfig(cfg), dynamodb.Config{
TableName: "example-configuration", KeyAttribute: "id", ValueAttribute: "value",
})
if err != nil {
panic(err)
}
value, err := provider.Get(ctx, "feature", dynamodb.GetOptions{})
if err != nil {
panic(err)
}
_ = value
}
Output: