parameterstore

package
v0.0.0-...-e25005f Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package parameterstore provides interfaces to interact with parameters (including sensitive secrets) stored in AWS Systems Manager Parameter Store.

Index

Constants

View Source
const Collection = "parameter_records"

Collection holds metadata information about parameters.

View Source
const ParamValueMaxLength = 8192

ParamValueMaxLength is the maximum allowed length (in bytes) of an SSM parameter value.

Variables

This section is empty.

Functions

func BumpParameterRecord

func BumpParameterRecord(ctx context.Context, db *mongo.Database, name string, lastUpdated time.Time) error

BumpParameterRecord bumps the parameter record to indicate that the parameter was changed. information. It will not modify the record if it already exists and its latest update is more recent than lastUpdated.

func GetBasename

func GetBasename(name string) string

GetBasename returns the parameter basename without any intermediate paths.

Types

type Parameter

type Parameter struct {
	// Name is the full name of the parameter, including its path. This is a
	// unique identifier. For example, the full name could be
	// /evergreen/path/to/my-parameter.
	Name string `bson:"-" json:"-" yaml:"-"`
	// Basename is the parameter's name without any hierarchical paths. For
	// example, if the full name including the path is
	// /evergreen/path/to/my-parameter, the basename is my-parameter.
	Basename string `bson:"-" json:"-" yaml:"-"`
	// Value is the parameter's plaintext value. This value should never be
	// persisted in the DB.
	Value string `bson:"-" json:"-" yaml:"-"`
}

Parameter represents a parameter kept in Parameter Store.

type ParameterManager

type ParameterManager struct {
	// contains filtered or unexported fields
}

ParameterManager is an intermediate abstraction layer for interacting with parameters in AWS Systems Manager Parameter Store. It supports caching to optimize parameter retrieval.

func NewParameterManager

func NewParameterManager(ctx context.Context, opts ParameterManagerOptions) (*ParameterManager, error)

NewParameterManager creates a new ParameterManager instance.

func (*ParameterManager) Delete

func (pm *ParameterManager) Delete(ctx context.Context, names ...string) error

Delete deletes the parameters given by the provided name(s).

func (*ParameterManager) Get

func (pm *ParameterManager) Get(ctx context.Context, names ...string) ([]Parameter, error)

Get retrieves the parameters given by the provided name(s). If some parameters cannot be found, they will not be returned. Use GetStrict to both get the parameters and validate that all the requested parameters were found.

func (*ParameterManager) GetStrict

func (pm *ParameterManager) GetStrict(ctx context.Context, names ...string) ([]Parameter, error)

GetStrict is the same as Get but verifies that all the requested parameter names were found before returning the result.

func (*ParameterManager) Put

func (pm *ParameterManager) Put(ctx context.Context, name, value string) (*Parameter, error)

Put adds or updates a parameter. This returns the created parameter.

type ParameterManagerOptions

type ParameterManagerOptions struct {
	// PathPrefix is the prefix path in the Parameter Store hierarchy. If set,
	// all parameters should be stored under this prefix.
	PathPrefix     string
	CachingEnabled bool
	SSMClient      SSMClient
	DB             *mongo.Database
}

ParameterManagerOptions represent options to create a parameter manager.

func (*ParameterManagerOptions) Validate

func (o *ParameterManagerOptions) Validate(ctx context.Context) error

Validate checks that the parameter manager options are valid and sets defaults where possible.

type ParameterRecord

type ParameterRecord struct {
	// Name is the unique full path identifier for the parameter. The name is
	// intentionally tagged as the BSON _id to ensure that the parameter's
	// unique name is the document's unique and primary identifier.
	Name string `bson:"_id" json:"_id"`
	// LastUpdated is the time the parameter was most recently updated.
	LastUpdated time.Time `bson:"last_updated" json:"last_updated"`
}

ParameterRecord stores metadata information about parameters. This never stores the value of the parameter itself.

func FindByNames

func FindByNames(ctx context.Context, db *mongo.Database, names ...string) ([]ParameterRecord, error)

FindByNames finds all parameter records by their parameter names.

func FindOneName

func FindOneName(ctx context.Context, db *mongo.Database, name string) (*ParameterRecord, error)

FindOneName finds one parameter record by its parameter name.

func (*ParameterRecord) Insert

func (pr *ParameterRecord) Insert(ctx context.Context, db *mongo.Database) error

type SSMClient

type SSMClient interface {
	// PutParameter puts a parameter into Parameter Store.
	PutParameter(context.Context, *ssm.PutParameterInput) (*ssm.PutParameterOutput, error)
	// DeleteParametersSimple is the same as DeleteParameters but only returns
	// the names of the deleted parameters rather than the full output.
	DeleteParametersSimple(context.Context, *ssm.DeleteParametersInput) ([]string, error)
	// DeleteParameters deletes the specified parameters. Parameter Store limits
	// how many parameters can be deleted per call, so implementations are
	// expected to handle batching transparently. The returned output slice
	// contains the output of each batched request.
	DeleteParameters(context.Context, *ssm.DeleteParametersInput) ([]*ssm.DeleteParametersOutput, error)
	// GetParametersSimple is the same as GetParameters but only returns the
	// parameter information rather than the full output.
	GetParametersSimple(context.Context, *ssm.GetParametersInput) ([]ssmTypes.Parameter, error)
	// GetParameters retrieves the specified parameters. Parameter Store
	// limits how many parameters can be retrieved per call, so implementations
	// must handle batching transparently. The returned output slice contains
	// the output of each batched request.
	GetParameters(context.Context, *ssm.GetParametersInput) ([]*ssm.GetParametersOutput, error)
}

SSMClient is an interface to interact with AWS Systems Manager (SSM) Parameter Store.

Directories

Path Synopsis
Package fakeparameter contains the data model and helpers for testing code that uses Parameter Store.
Package fakeparameter contains the data model and helpers for testing code that uses Parameter Store.

Jump to

Keyboard shortcuts

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