https://github.com/oreo0725/ssm2dotenv
Replace aws ssm parameter keys into values in the .env file
https://github.com/oreo0725/ssm2dotenv
aws aws-ssm dotenv golang parameter-store ssm
Last synced: 4 months ago
JSON representation
Replace aws ssm parameter keys into values in the .env file
- Host: GitHub
- URL: https://github.com/oreo0725/ssm2dotenv
- Owner: oreo0725
- Created: 2022-10-08T15:16:44.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-11T01:48:21.000Z (over 3 years ago)
- Last Synced: 2024-06-21T10:59:24.434Z (almost 2 years ago)
- Topics: aws, aws-ssm, dotenv, golang, parameter-store, ssm
- Language: Go
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ssm2dotenv
Inspired by [ssm-env](https://github.com/remind101/ssm-env).
Usually, if you are using libraries like [godotenv](https://github.com/joho/godotenv) to load environment variables from a `.env` file, but you won't like to place the secrets in the `.env` file, you can use `ssm2dotenv` command to load the secrets from AWS SSM Parameter Store.
## Usage
Suppose that you have the following parameters in aws SSM:
| key | value |
|----------------------|-----------------------------|
| /app-api/test/DB_DSN | postgres://xxx:yyyy/test_db |
| /app-api/prod/DB_DSN | postgres://xxx:yyyy/prod_db |
And you have the following `sample.env` template file:
```dotenv
ENV=test
DB_META_DSNS=ssm:///app-api/${env}/DB_DSN
PORT=8080
```
Then, you can run the following command to get the env file
```bash
$ ssm2dotenv --env test -i ./sample.env -o ./.env
```
So you can get the env file including secrets just only existing during the local development or your CI/CD pipeline.
```dotenv
ENV=test
DB_META_DSNS=postgres://xxx:yyyy/test_db
PORT=8080
```