Documentation ¶
Overview ¶
Package paramstore 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 NewVariable to construct a *runtimevar.Variable.
As ¶
paramstore exposes the following types for As:
- Snapshot: *ssm.GetParameterOutput, *ssm.DescribeParametersOutput
- Error: awserr.Error
Example ¶
package main import ( "context" "log" "github.com/aws/aws-sdk-go/aws/session" "gocloud.dev/runtimevar" "gocloud.dev/runtimevar/paramstore" ) // MyConfig is a sample configuration struct. type MyConfig struct { Server string Port int } func main() { // Establish an AWS session. // See https://docs.aws.amazon.com/sdk-for-go/api/aws/session/ for more info. session, err := session.NewSession(nil) if err != nil { log.Fatal(err) } // 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 := paramstore.NewVariable(session, "cfg-variable-name", decoder, nil) if err != nil { log.Fatal(err) } defer v.Close() // We can now read the current value of the variable from v. snapshot, err := v.Watch(context.Background()) if err != nil { log.Fatal(err) } cfg := snapshot.Value.(MyConfig) _ = cfg }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewVariable ¶ added in v0.9.0
func NewVariable(sess client.ConfigProvider, name string, decoder *runtimevar.Decoder, opts *Options) (*runtimevar.Variable, error)
NewVariable 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.
Types ¶
Click to show internal directories.
Click to hide internal directories.