gofor-little / cfg

Securely load config data from AWS SecretsManager.

Home Page:https://pkg.go.dev/github.com/gofor-little/config

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A package for loading config data from AWS SecretsManager

GitHub tag (latest SemVer pre-release) GitHub go.mod Go version License: MIT GitHub Workflow Status Go Report Card PkgGoDev

Introduction

  • Secure config loading.
  • Support AWS SecretsManager.
  • Easy JSON unmarshaling into a struct.

Example

package main

import (
	"context"

	"github.com/gofor-little/cfg"
)

type Config struct {
	SomeStringValue string `json:"someStringValue"`
	SomeIntValue    int    `json:"someIntValue"`
}

func main() {
	// Initialize the cfg package.
	if err := cfg.Initialize(context.Background(), "AWS_PROFILE", "AWS_REGION"); err != nil {
		panic(err)
	}

	// Load and parse the config data into the passed Config struct.
	config := &Config{}
	if err := cfg.Load(context.Background(), "AWS_SECRET_ARN", config); err != nil {
		panic(err)
	}
}

Testing

Ensure the following environment variables are set, usually with a .env file.

  • AWS_PROFILE (an AWS CLI profile name)
  • AWS_REGION (a valid AWS region)

Run go test -v ./... in the root directory.

About

Securely load config data from AWS SecretsManager.

https://pkg.go.dev/github.com/gofor-little/config

License:MIT License


Languages

Language:Go 100.0%