ssmparams

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2021 License: MIT Imports: 3 Imported by: 1

README

ssmparams

ssmparams provides a simple method to asynchronosly fetch parameters from the AWS Systems Manager Parameter Store.

Go Go Report Card GitHub go.mod Go version Go Reference

Configuration

This module expects a configured AWS credentials file with a default profile. See https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html for more details.

Example

package main

import (
	"github.com/davecgh/go-spew/spew"
	"github.com/rmrfslashbin/ssmparams"
	"github.com/sirupsen/logrus"
)

func main() {
	// awscli profile name
	awsProfile := "default"
	awsRegion := "us-east-1"

	// Set up a new ssmparams client
	params, err := ssmparams.New(
		ssmparams.SetProfile(awsProfile),
		ssmparams.SetRegion(awsRegion),
	)
	if err != nil {
		panic(err)
	}

	// Set up a string slice of parameter names to retrieve
	request := []string{
		"/first/param/to/request/secret",
		"/first/param/to/request/secret",
		"/second/param/to/request",
	}

	// Retrieve the parameters
	outputs, err := params.GetParams(request)
	if err != nil {
		panic(err)
	}

	// Check if invalid parameters were returned
	if len(outputs.InvalidParameters) > 0 {
		logrus.WithFields(logrus.Fields{
			"params": outputs.InvalidParameters,
		}).Error("parameter(s) not found")
	}

	// Dump the output
	spew.Dump(outputs.Parameters)
}

Documentation

Overview

Package ssmparams queries Amazon Web Services (AWS) Systems Manager (formerly known as SSM) Parameter Store services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v0.0.8

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

Config is used to configure the ssmparams client.

func New

func New(opts ...func(*Config)) (*Config, error)

New is a factory function for creating a new Config

func (*Config) GetParams added in v0.0.8

func (config *Config) GetParams(paramNames []string) (*ParamOutput, error)

GetParam gets a parameter from AWS Parameter Store.

func (*Config) PutParam added in v0.0.8

func (config *Config) PutParam(params *ssm.PutParameterInput) (*ssm.PutParameterOutput, error)

PutParam puts a parameter into AWS Parameter Store.

type Option added in v0.0.8

type Option func(config *Config)

Used to manage varidic options

func SetProfile added in v0.0.8

func SetProfile(profile string) Option

SetProfile sets the AWS profile to use.

func SetRegion added in v0.0.8

func SetRegion(region string) Option

SetRegion sets the AWS region to use.

type ParamOutput

type ParamOutput struct {
	// Parameters is a map of parameter names to values.
	Parameters map[string]interface{}

	// InvalidParameters is a list of parameter names that were not found.
	InvalidParameters []string
}

ParamOutput is the output of the GetParam function.

Jump to

Keyboard shortcuts

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