Skip to content

ysugimoto/jsonenv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jsonenv

This package parse JSON-formatted environment value and set environment with key-value.

Typical usecase is AWS ECS using Secret Manager. On running ECS task with secrets task definition, the runtime assignes AWS Secret Manager's name as environment key and JSON-Stringified string as environment value. This package intends to parse and extract, and set to environment.

Usage

import (
    "fmt"
    "log"
    "os"

    "github.com/ysugimoto/jsonenv"
)

// Case: json env exists like `example-secret={"FOO":"BAR"}` via AWS Secrets Manager
func main() {
    if err := jsonenv.Extract("example-secret"); err != nil {
        log.Fatalln(err)
    }
    // do something with extracted environment variables.
    fmt.Println(os.Getenv("FOO")) // outputs BAR
}

Test

go test

License

MIT

Author

Yoshiaki Sugimoto

About

Extract JSON-formatted environment value

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages