awsparamstore

package
v0.0.0-...-04d4c2e Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2025 License: Apache-2.0, Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package awsparamstore provides a runtimevar implementation with variables read from AWS Systems Manager Parameter Store (https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-paramstore.html) Use OpenVariable to construct a *runtimevar.Variable.

URLs

For runtimevar.OpenVariable, awsparamstore registers for the scheme "awsparamstore". The default URL opener will use an AWS session with the default credentials and configuration.

To customize the URL opener, or for more details on the URL format, see URLOpener. See https://gocloud.dev/concepts/urls/ for background information.

As

awsparamstore exposes the following types for As:

  • Snapshot: *ssm.GetParameterOutput
  • Error: any error type returned by the service, notably smithy.APIError
Example (OpenVariableFromURL)
package main

import (
	"context"
	"log"

	"github.com/DataDog/iceberg-go/go-cloud/runtimevar"
)

func main() {
	// PRAGMA: This example is used on gocloud.dev; PRAGMA comments adjust how it is shown and can be ignored.
	// PRAGMA: On gocloud.dev, add a blank import: _ "gocloud.dev/runtimevar/awsparamstore"
	// PRAGMA: On gocloud.dev, hide lines until the next blank line.
	ctx := context.Background()

	// runtimevar.OpenVariable creates a *runtimevar.Variable from a URL.
	v, err := runtimevar.OpenVariable(ctx, "awsparamstore://myvar?region=us-west-1&decoder=string")
	if err != nil {
		log.Fatal(err)
	}
	defer v.Close()
}

Index

Examples

Constants

View Source
const Scheme = "awsparamstore"

Scheme is the URL scheme awsparamstore registers its URLOpener under on runtimevar.DefaultMux.

Variables

View Source
var OpenVariableV2 = OpenVariable
View Source
var Set = wire.NewSet(
	Dial,
)

Set holds Wire providers for this package.

Functions

func Dial

func Dial(cfg aws.Config) *ssm.Client

Dial gets an AWS SSM service client using the AWS SDK V2.

func OpenVariable

func OpenVariable(client *ssm.Client, name string, decoder *runtimevar.Decoder, opts *Options) (*runtimevar.Variable, error)

OpenVariable constructs a *runtimevar.Variable backed by the variable name in AWS Systems Manager Parameter Store, using AWS SDK V2. Parameter Store returns raw bytes; provide a decoder to decode the raw bytes into the appropriate type for runtimevar.Snapshot.Value. See the runtimevar package documentation for examples of decoders.

Example
package main

import (
	"context"
	"log"

	"github.com/DataDog/iceberg-go/go-cloud/runtimevar"
	"github.com/DataDog/iceberg-go/go-cloud/runtimevar/awsparamstore"
	"github.com/aws/aws-sdk-go-v2/config"
	"github.com/aws/aws-sdk-go-v2/service/ssm"
)

func main() {
	// PRAGMA: This example is used on gocloud.dev; PRAGMA comments adjust how it is shown and can be ignored.

	// Establish a AWS V2 Config.
	// See https://aws.github.io/aws-sdk-go-v2/docs/configuring-sdk/ for more info.
	ctx := context.Background()
	cfg, err := config.LoadDefaultConfig(ctx)
	if err != nil {
		log.Fatal(err)
	}

	// Construct a *runtimevar.Variable that watches the variable.
	client := ssm.NewFromConfig(cfg)
	v, err := awsparamstore.OpenVariable(client, "cfg-variable-name", runtimevar.StringDecoder, nil)
	if err != nil {
		log.Fatal(err)
	}
	defer v.Close()
}

Types

type Options

type Options struct {
	// WaitDuration controls the rate at which Parameter Store is polled.
	// Defaults to 30 seconds.
	WaitDuration time.Duration
}

Options sets options.

type URLOpener

type URLOpener struct {
	// Decoder specifies the decoder to use if one is not specified in the URL.
	// Defaults to runtimevar.BytesDecoder.
	Decoder *runtimevar.Decoder

	// Options specifies the options to pass to New.
	Options Options
}

URLOpener opens AWS Paramstore URLs like "awsparamstore://myvar".

See https://pkg.go.dev/gocloud.dev/aws#V2ConfigFromURLParams.

In addition, the following URL parameters are supported:

  • decoder: The decoder to use. Defaults to URLOpener.Decoder, or runtimevar.BytesDecoder if URLOpener.Decoder is nil. See runtimevar.DecoderByName for supported values.
  • wait: The poll interval, in time.ParseDuration formats. Defaults to 30s.

func (*URLOpener) OpenVariableURL

func (o *URLOpener) OpenVariableURL(ctx context.Context, u *url.URL) (*runtimevar.Variable, error)

OpenVariableURL opens the variable at the URL's path. See the package doc for more details.

Jump to

Keyboard shortcuts

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