https://github.com/lucashfreitas/aws-parameter-dotenv
Tiny Library to load environment variables directly from AWS System parameter store.
https://github.com/lucashfreitas/aws-parameter-dotenv
aws dot-env parameter-store
Last synced: 7 months ago
JSON representation
Tiny Library to load environment variables directly from AWS System parameter store.
- Host: GitHub
- URL: https://github.com/lucashfreitas/aws-parameter-dotenv
- Owner: lucashfreitas
- License: mit
- Created: 2022-01-21T11:51:52.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-01-07T19:19:15.000Z (over 3 years ago)
- Last Synced: 2025-01-06T20:15:31.500Z (over 1 year ago)
- Topics: aws, dot-env, parameter-store
- Language: TypeScript
- Homepage:
- Size: 227 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# aws-parameter-dotenv
Tiny Library/wrapper around AWS System Parameter Store to load environment variables directly from AWS.
# Use
`yarn add aws-parameter-dotenv` or `npm i aws-parameter-dotenv`.
This library is very opinated on how to name/structure the parameter names following this
structure: `{projectName}/{environmentName}/{parameterName}`. The parameterName should be **camelCase**.
- You can use the library to add parameters as follow:
```typescript
import awsparamterdotenv from "aws-parameter-dot-env";
/**
* Add environment variables
* */
await awsparamterdotenv({
project: "projectName",
environment: "environment",
region: "us-east-1",
}).addParameter({
name: "myParameter",
value: "myValue",
secret: true, // should be stored as secure string
});
```
- Or just load the parameters
```typescript
import awsparamterdotenv from "aws-parameter-dot-env";
/**
* Load all the environment variables
* */
await awsparamterdotenv({
project: "projectName",
environment: "environment",
region: "us-east-1",
}).load();
process.env.myParameter === "myValue"; // is TRUE
```
# Testing
- `index.unit.spec.ts` contains the unit tests
- `index.integration.spec.ts` contains the integration tests: It's required valid AWS Credentials accounts with IAM permission to execute operations on SMS. To run the integration tests rename the `.env.example` to `.env` and add your AWS Credentials.