Skip to content
This repository has been archived by the owner on Jun 15, 2019. It is now read-only.
/ fig Public archive

Configuration management in Go

License

Notifications You must be signed in to change notification settings

hookactions/fig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

No longer maintained, in favor of: https://github.com/hookactions/config

fig

header CircleCI

Usage

AWS

Pre-process config values by reading secrets from AWS.

// main.go
package main

import (
	"context"
	"fmt"

	figAws "github.com/hookactions/fig/aws"
	"github.com/spf13/viper"
)

func main() {
	viper.SetConfigName("config")
	viper.AddConfigPath(".")

	if err := viper.ReadInConfig(); err != nil {
		panic(err)
	}

	fig, err := figAws.New(nil)
	if err != nil {
		panic(err)
	}

	fig.PreProcessConfigItems(context.Background())

	value := viper.GetString("my_var")
	fmt.Println(value)
}
echo "my_var: sm://foo" >> config.yaml
go run main.go

Supported prefixes

  • sm:// – Get string value from secrets manager
  • smb:// – Get binary value from secrets manager
  • ssm:// – Get string value from parameter store
    • Note: decryption of the value is automatically requested.
  • ssmb64:// – Get base64 encoded binary value from parameter store
    • Note: decryption of the value is automatically requested.

AWS via Env

Pre-process config values by reading secrets from AWS.

// main.go
package main

import (
	"context"
	"fmt"
	"os"

	"github.com/hookactions/fig/awsEnv"
)

func main() {
	fig, err := awsEnv.New()
	if err != nil {
		panic(err)
	}

	fmt.Println(fig.GetEnv(context.Background(), "MY_VAR"))
}
MY_VAR=sm://foo go run main.go

Supported prefixes

  • sm:// – Get string value from secrets manager
  • ssm:// – Get string value from parameter store
    • Note: decryption of the value is automatically requested.