go-ssm-config alternatives and similar packages
Based on the "Configuration" category.
Alternatively, view go-ssm-config alternatives based on common mentions on social networks and blogs.
-
koanf
Simple, extremely lightweight, extensible, configuration management library for Go. Supports JSON, TOML, YAML, env, command line, file, S3 etc. Alternative to viper. -
konfig
Composable, observable and performant config handling for Go for the distributed processing era -
gookit/config
📝 Go configuration manage(load,get,set,export). support JSON, YAML, TOML, Properties, INI, HCL, ENV and Flags. Multi file load, data override merge, parse ENV var. Go应用配置加载管理,支持多种格式,多文件加载,远程文件加载,支持数据合并,解析环境变量名 -
gcfg
read INI-style configuration files into Go structs; supports user-defined types and subsections -
goConfig
DISCONTINUED. goconfig uses a struct as input and populates the fields of this struct with parameters from command line, environment variables and configuration file. -
joshbetz/config
🛠 A configuration library for Go that parses environment variables, JSON files, and reloads automatically on SIGHUP. -
configuro
An opinionated configuration loading framework for Containerized and Cloud-Native applications. -
hocon
go implementation of lightbend's HOCON configuration library https://github.com/lightbend/config -
configure
Configure is a Go package that gives you easy configuration of your project through redundancy -
Genv
Genv is a library for Go (golang) that makes it easy to read and use environment variables in your projects. It also allows environment variables to be loaded from the .env file. -
swap
Instantiate/configure structs recursively, based on build environment. (YAML, TOML, JSON and env).
SaaSHub - Software Alternatives and Reviews
Do you think we are missing an alternative of go-ssm-config or a related project?
README
ssmconfig
import "github.com/ianlopshire/go-ssm-config"
SSMConfig is a utility for loading configuration parameters from AWS SSM (Parameter Store) directly into a struct. This package is largely inspired by kelseyhightower/envconfig.
Motivation
This package was created to reduce the boilerplate code required when using Parameter Store to provide configuration to AWS Lambda functions. It should be suitable for additional applications.
Usage
Set some parameters in AWS Parameter Store:
Name | Value | Type | Key ID |
---|---|---|---|
/exmaple_service/prod/debug | false | String | - |
/exmaple_service/prod/port | 8080 | String | - |
/exmaple_service/prod/user | Ian | String | - |
/exmaple_service/prod/rate | 0.5 | String | - |
/exmaple_service/prod/secret | zOcZkAGB6aEjN7SAoVBT | SecureString | alias/aws/ssm |
Write some code:
package main
import (
"fmt"
"log"
"time"
ssmconfig "github.com/ianlopshire/go-ssm-config"
)
type Config struct {
Debug bool `ssm:"debug" default:"true"`
Port int `ssm:"port"`
User string `ssm:"user"`
Rate float32 `ssm:"rate"`
Secret string `ssm:"secret" required:"true"`
}
func main() {
var c Config
err := ssmconfig.Process("/example_service/prod/", &c)
if err != nil {
log.Fatal(err.Error())
}
format := "Debug: %v\nPort: %d\nUser: %s\nRate: %f\nSecret: %s\n"
_, err = fmt.Printf(format, c.Debug, c.Port, c.User, c.Rate, c.Secret)
if err != nil {
log.Fatal(err.Error())
}
}
Result:
Debug: false
Port: 8080
User: Ian
Rate: 0.500000
Secret: zOcZkAGB6aEjN7SAoVBT
Additional examples can be found in godoc.
Struct Tag Support
ssmconfig supports the use of struct tags to specify parameter name, default value, and required parameters.
type Config struct {
Param string `ssm:"param"`
RequiredParam string `ssm:"required_param" required:"true"`
DefaultParam string `ssm:"default_param" default:"foobar"`
}
The ssm
tag is used to lookup the parameter in Parameter Store. It is joined to the base path passed into Process()
.
If the ssm
tag is missing ssmconfig will ignore the struct field.
The default
tag is used to set the default value of a parameter. The default value will only be set if Parameter Store
returns the parameter as invalid.
The required
tag is used to mark a parameter as required. If Parameter Store returns a required parameter as invalid,
ssmconfig will return an error.
The behavior of using the default
and required
tags on the same struct field is currently undefined.
Supported Struct Field Types
ssmconfig supports these struct field types:
- string
- int, int8, int16, int32, int64
- bool
- float32, float64
More supported types may be added in the future.
Licence
MIT