gocloud.dev: gocloud.dev/runtimevar/awsparamstore Index | Examples | Files

package awsparamstore

import "gocloud.dev/runtimevar/awsparamstore"

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.


For runtimevar.OpenVariable, awsparamstore registers for the scheme "awsparamstore". The default URL opener will use an AWS session with the default credentials and configuration; see https://docs.aws.amazon.com/sdk-for-go/api/aws/session/ for more details. To customize the URL opener, or for more details on the URL format, see URLOpener. See https://gocloud.dev/concepts/urls/ for background information.


awsparamstore exposes the following types for As:

- Snapshot: *ssm.GetParameterOutput, *ssm.DescribeParametersOutput
- Error: awserr.Error


// runtimevar.OpenVariable creates a *runtimevar.Variable from a URL.
ctx := context.Background()
v, err := runtimevar.OpenVariable(ctx, "awsparamstore://myvar?region=us-west-1")
if err != nil {

snapshot, err := v.Latest(ctx)
_, _ = snapshot, err



Package Files



const Scheme = "awsparamstore"

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


var Set = wire.NewSet(

Set holds Wire providers for this package.

func OpenVariable Uses

func OpenVariable(sess client.ConfigProvider, 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. 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.


// Establish an AWS session.
// See https://docs.aws.amazon.com/sdk-for-go/api/aws/session/ for more info.
sess, err := session.NewSession(nil)
if err != nil {

// Create a decoder for decoding JSON strings into MyConfig.
decoder := runtimevar.NewDecoder(MyConfig{}, runtimevar.JSONDecode)

// Construct a *runtimevar.Variable that watches the variable.
// For this example, the Parameter Store variable being referenced
// should have a JSON string that decodes into MyConfig.
v, err := awsparamstore.OpenVariable(sess, "cfg-variable-name", decoder, nil)
if err != nil {
defer v.Close()

// We can now read the current value of the variable from v.
snapshot, err := v.Latest(context.Background())
if err != nil {
cfg := snapshot.Value.(MyConfig)
_ = cfg

type Options Uses

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 Uses

type URLOpener struct {
    // ConfigProvider must be set to a non-nil value.
    ConfigProvider client.ConfigProvider

    // 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 gocloud.dev/aws/ConfigFromURLParams for supported query parameters that affect the default AWS session.

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.

func (*URLOpener) OpenVariableURL Uses

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.

Package awsparamstore imports 15 packages (graph) and is imported by 4 packages. Updated 2019-05-16. Refresh now. Tools for package owners.