Inspired by Berglas.
This tool will resolve the environment referenced to AWS SecretManager to the secret value.
secretsmanager:ListSecrets
secretsmanager:GetSecretValue
secretsmanager:DescribeSecret
The reference must follow this format {ReferencePrefix}{AWS SecretName}/{AWS SecretKey}
The default {ReferencePrefix}
is awssm://
. To change this prefix use option.WithReferencePreifx("abc://")
reference := "awssm://my-aws-secret-name/MY_SECRET"
client := awssm.NewClient()
resolved, err := client.Resolve(reference)
if err != nil {
fmt.Println("not resolved")
} else {
fmt.Printf("resolved to '%s'\n", resolved)
}
To automatic resolve the environment variables, import auto
package to the main file.
// main.go
import (
_ "github.com/hypcode-th/go-awssm-env/awssm/auto"
)
func main() {
...
}