Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/huk-coburg/go-envconfig-secretsmanager-mutator
https://github.com/huk-coburg/go-envconfig-secretsmanager-mutator
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/huk-coburg/go-envconfig-secretsmanager-mutator
- Owner: HUK-COBURG
- License: mit
- Created: 2024-12-09T12:31:01.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2024-12-09T12:39:10.000Z (about 2 months ago)
- Last Synced: 2024-12-10T05:55:53.284Z (about 2 months ago)
- Language: Go
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AWS Secrets Manager Config Mutator
This package is an extension for https://github.com/sethvargo/go-envconfig.
It implements a mutator to fetch secrets from the AWS Secrets Manager.For every environment variable with the prefix `SECRET_`, the mutator assumes that the value configured as an
environment variable is the ARN or the Name of a secret in the Secrets Manager.
The mutator calls `GetSecretValue` with the provided value as the `SecretId` and replaces the original value with the
`SecretString` returned by the Secrets Manager.---
## Usage
1. Create a secret in the AWS Secret Manager.
In this example we assume that a secret named `FavoriteAnimal` is configured with the value `penguin`.
2. Configure an environment variable where the secret should be placed in with a key with the prefix `SECRET_` and a
value containing either the name or the ARN of the secret.
```bash
SECRET_FAVORITE_ANIMAL=FavoriteAnimal
```3. Add the variable to your application's config.
```go
type MyConfig struct{
FavoriteAnimal string `env:"SECRET_FAVORITE_ANIMAL"`
//additional values, also non-secret values possible
}```
4. Process your config with the mutator configured.
```go
package mainimport (
"context"
"log""github.com/huk-coburg/go-envconfig-secretsmanager-mutator"
"github.com/sethvargo/go-envconfig"
)func main() {
ctx := context.Background()var c MyConfig
if err := envconfig.Process(ctx, &c, envconfigsecret.NewSecretsManagerMutator(ctx)); err != nil {
log.Fatal(err)
}// c.FavoriteAnimal = "penguin"
}
```---
## Contributions
Feel free to open issues or submit pull requests to improve the package. Feedback and suggestions are always welcome!---