env-secrets 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.devcontainer/devcontainer.json +10 -6
- package/.dockerignore +9 -0
- package/.eslintignore +4 -2
- package/.github/dependabot.yml +4 -0
- package/.github/workflows/build-main.yml +6 -2
- package/.github/workflows/deploy-docs.yml +50 -0
- package/.github/workflows/e2e-tests.yaml +54 -0
- package/.github/workflows/lint.yaml +6 -2
- package/.github/workflows/release.yml +2 -2
- package/.github/workflows/snyk.yaml +5 -1
- package/.github/workflows/unittests.yaml +9 -66
- package/.lintstagedrc +2 -7
- package/.prettierignore +6 -0
- package/AGENTS.md +149 -0
- package/Dockerfile +14 -0
- package/README.md +331 -13
- package/__e2e__/README.md +160 -0
- package/__e2e__/index.test.ts +334 -32
- package/__e2e__/setup.ts +58 -0
- package/__e2e__/utils/debug-logger.ts +45 -0
- package/__e2e__/utils/test-utils.ts +645 -0
- package/__tests__/index.test.ts +266 -9
- package/__tests__/vaults/secretsmanager.test.ts +460 -0
- package/__tests__/vaults/utils.test.ts +9 -9
- package/dist/index.js +36 -10
- package/dist/vaults/secretsmanager.js +17 -5
- package/dist/vaults/utils.js +2 -2
- package/docker-compose.yaml +29 -0
- package/docs/AWS.md +257 -0
- package/jest.config.js +3 -1
- package/jest.e2e.config.js +8 -0
- package/package.json +10 -7
- package/src/index.ts +44 -10
- package/src/vaults/secretsmanager.ts +16 -5
- package/src/vaults/utils.ts +6 -4
- package/website/docs/advanced-usage.mdx +399 -0
- package/website/docs/best-practices.mdx +416 -0
- package/website/docs/cli-reference.mdx +204 -0
- package/website/docs/examples.mdx +960 -0
- package/website/docs/faq.mdx +302 -0
- package/website/docs/index.mdx +56 -0
- package/website/docs/installation.mdx +30 -0
- package/website/docs/overview.mdx +17 -0
- package/website/docs/production-deployment.mdx +622 -0
- package/website/docs/providers/aws-secrets-manager.mdx +28 -0
- package/website/docs/security.mdx +122 -0
- package/website/docs/troubleshooting.mdx +236 -0
- package/website/docs/tutorials/local-dev/devcontainer-localstack.mdx +31 -0
- package/website/docs/tutorials/local-dev/docker-compose.mdx +22 -0
- package/website/docs/tutorials/local-dev/nextjs.mdx +18 -0
- package/website/docs/tutorials/local-dev/node-python-go.mdx +39 -0
- package/website/docs/tutorials/local-dev/quickstart.mdx +23 -0
- package/website/docusaurus.config.ts +89 -0
- package/website/package.json +21 -0
- package/website/sidebars.ts +33 -0
- package/website/src/css/custom.css +1 -0
- package/website/static/img/env-secrets.png +0 -0
- package/website/static/img/favicon.ico +0 -0
- package/website/static/img/logo.svg +4 -0
- package/website/yarn.lock +8764 -0
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: FAQ
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Frequently Asked Questions
|
|
6
|
+
|
|
7
|
+
## General Questions
|
|
8
|
+
|
|
9
|
+
### What is env-secrets?
|
|
10
|
+
|
|
11
|
+
`env-secrets` is a Node.js CLI tool that retrieves secrets from AWS Secrets Manager and injects them as environment variables into your running applications. It's designed to be simple, secure, and easy to integrate into your existing workflows.
|
|
12
|
+
|
|
13
|
+
### How does env-secrets work?
|
|
14
|
+
|
|
15
|
+
1. **Retrieves secrets** from AWS Secrets Manager using the AWS SDK
|
|
16
|
+
2. **Parses JSON secrets** and converts them to environment variables
|
|
17
|
+
3. **Spawns a child process** with the injected environment variables
|
|
18
|
+
4. **Cleans up** when the process exits
|
|
19
|
+
|
|
20
|
+
### Where are secrets stored?
|
|
21
|
+
|
|
22
|
+
Nowhere locally. `env-secrets` only sets environment variables for the spawned process. Secrets are never:
|
|
23
|
+
|
|
24
|
+
- Stored on disk
|
|
25
|
+
- Cached in memory
|
|
26
|
+
- Logged to files
|
|
27
|
+
- Exposed in process lists
|
|
28
|
+
|
|
29
|
+
## AWS Integration
|
|
30
|
+
|
|
31
|
+
### Can I use profiles instead of env vars?
|
|
32
|
+
|
|
33
|
+
Yes — pass `-p <profile>` to use a specific AWS profile:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
env-secrets aws -s my-secret -r us-east-1 -p my-profile -- node app.js
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Does it support IAM roles?
|
|
40
|
+
|
|
41
|
+
Yes! `env-secrets` respects AWS credential precedence:
|
|
42
|
+
|
|
43
|
+
1. Environment variables (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`)
|
|
44
|
+
2. IAM roles (EC2, ECS, Lambda)
|
|
45
|
+
3. AWS profiles
|
|
46
|
+
|
|
47
|
+
### What permissions do I need?
|
|
48
|
+
|
|
49
|
+
Minimal IAM policy for `env-secrets`:
|
|
50
|
+
|
|
51
|
+
> **Note:** In the ARN below, replace `region` with your AWS region (e.g., `us-east-1`) and `account` with your AWS account ID.
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"Version": "2012-10-17",
|
|
56
|
+
"Statement": [
|
|
57
|
+
{
|
|
58
|
+
"Effect": "Allow",
|
|
59
|
+
"Action": "secretsmanager:GetSecretValue",
|
|
60
|
+
"Resource": "arn:aws:secretsmanager:region:account:secret:your-secret-name*"
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Can I use it with AWS Lambda?
|
|
67
|
+
|
|
68
|
+
Yes, but with some considerations:
|
|
69
|
+
|
|
70
|
+
- Lambda has a 15-minute execution limit
|
|
71
|
+
- Use IAM roles for authentication
|
|
72
|
+
- Consider using AWS SDK directly for Lambda functions
|
|
73
|
+
|
|
74
|
+
## Security Questions
|
|
75
|
+
|
|
76
|
+
### Are secrets logged?
|
|
77
|
+
|
|
78
|
+
No, secret values are never logged. Only metadata and API calls are logged when using debug mode.
|
|
79
|
+
|
|
80
|
+
### How secure is the process?
|
|
81
|
+
|
|
82
|
+
Very secure:
|
|
83
|
+
|
|
84
|
+
- **No local storage** of secrets
|
|
85
|
+
- **Process isolation** - secrets only in child process
|
|
86
|
+
- **Clean exit** - environment variables cleaned up
|
|
87
|
+
- **HTTPS only** - all AWS API calls encrypted
|
|
88
|
+
|
|
89
|
+
### Can other processes see the secrets?
|
|
90
|
+
|
|
91
|
+
No, environment variables are only available to the spawned child process. The parent shell and other processes cannot access them.
|
|
92
|
+
|
|
93
|
+
## Usage Questions
|
|
94
|
+
|
|
95
|
+
### Does it support multiple providers?
|
|
96
|
+
|
|
97
|
+
Currently, `env-secrets` supports AWS Secrets Manager. Contributions are welcome for other vaults like:
|
|
98
|
+
|
|
99
|
+
- HashiCorp Vault
|
|
100
|
+
- Azure Key Vault
|
|
101
|
+
- Google Secret Manager
|
|
102
|
+
|
|
103
|
+
### Can I use it with Docker?
|
|
104
|
+
|
|
105
|
+
Yes! Several ways:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# Direct integration
|
|
109
|
+
env-secrets aws -s docker-secrets -r us-east-1 -- docker run -e DATABASE_URL my-app
|
|
110
|
+
|
|
111
|
+
# In Dockerfile
|
|
112
|
+
ENTRYPOINT ["env-secrets", "aws", "-s", "docker/app", "-r", "us-east-1", "--"]
|
|
113
|
+
CMD ["node", "app.js"]
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Can I use it with Kubernetes?
|
|
117
|
+
|
|
118
|
+
Yes! Use it in your deployment:
|
|
119
|
+
|
|
120
|
+
```yaml
|
|
121
|
+
command: ['env-secrets']
|
|
122
|
+
args: ['aws', '-s', 'k8s/app', '-r', 'us-east-1', '--', 'node', 'app.js']
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### How do I debug issues?
|
|
126
|
+
|
|
127
|
+
Enable debug logging:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
# Basic debug
|
|
131
|
+
DEBUG=env-secrets env-secrets aws -s my-secret -r us-east-1 -- env
|
|
132
|
+
|
|
133
|
+
# Detailed debug
|
|
134
|
+
DEBUG=env-secrets,env-secrets:secretsmanager env-secrets aws -s my-secret -r us-east-1 -- env
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Performance Questions
|
|
138
|
+
|
|
139
|
+
### Is it fast?
|
|
140
|
+
|
|
141
|
+
Yes, but depends on:
|
|
142
|
+
|
|
143
|
+
- **Network latency** to AWS
|
|
144
|
+
- **Secret size** (keep secrets small)
|
|
145
|
+
- **Region proximity** (use same region as your app)
|
|
146
|
+
- **AWS SDK warm-up** (first call may be slower)
|
|
147
|
+
|
|
148
|
+
### Does it cache secrets?
|
|
149
|
+
|
|
150
|
+
No, `env-secrets` doesn't cache secrets. Each run fetches fresh secrets from AWS Secrets Manager.
|
|
151
|
+
|
|
152
|
+
### Can I optimize performance?
|
|
153
|
+
|
|
154
|
+
Yes:
|
|
155
|
+
|
|
156
|
+
- Use IAM roles instead of access keys
|
|
157
|
+
- Keep secrets small and focused
|
|
158
|
+
- Use VPC endpoints for AWS Secrets Manager
|
|
159
|
+
- Run in the same region as your secrets
|
|
160
|
+
|
|
161
|
+
## Troubleshooting
|
|
162
|
+
|
|
163
|
+
### "Unable to connect to AWS"
|
|
164
|
+
|
|
165
|
+
Check your AWS configuration:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
# Verify AWS CLI works
|
|
169
|
+
aws sts get-caller-identity
|
|
170
|
+
|
|
171
|
+
# Check environment variables
|
|
172
|
+
echo $AWS_ACCESS_KEY_ID
|
|
173
|
+
echo $AWS_SECRET_ACCESS_KEY
|
|
174
|
+
echo $AWS_DEFAULT_REGION
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### "Secret not found"
|
|
178
|
+
|
|
179
|
+
Verify the secret exists:
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
# List secrets
|
|
183
|
+
aws secretsmanager list-secrets --region us-east-1
|
|
184
|
+
|
|
185
|
+
# Check specific secret
|
|
186
|
+
aws secretsmanager describe-secret --secret-id my-secret --region us-east-1
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### "Access denied"
|
|
190
|
+
|
|
191
|
+
Check your IAM permissions:
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
# Test secret access
|
|
195
|
+
aws secretsmanager get-secret-value --secret-id my-secret --region us-east-1
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Environment variables not injected
|
|
199
|
+
|
|
200
|
+
Check your secret format:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
# Verify JSON format
|
|
204
|
+
aws secretsmanager get-secret-value --secret-id my-secret --region us-east-1 --query SecretString | jq .
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Development Questions
|
|
208
|
+
|
|
209
|
+
### Can I use it for local development?
|
|
210
|
+
|
|
211
|
+
Yes! Create development secrets:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
aws secretsmanager create-secret \
|
|
215
|
+
--name dev/myapp \
|
|
216
|
+
--secret-string '{"DATABASE_URL":"postgres://dev:dev@localhost:5432/dev"}'
|
|
217
|
+
|
|
218
|
+
env-secrets aws -s dev/myapp -r us-east-1 -- npm run dev
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Can I use it with LocalStack?
|
|
222
|
+
|
|
223
|
+
Yes! Perfect for local development:
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
# Set up LocalStack
|
|
227
|
+
export AWS_ENDPOINT_URL=http://localhost:4566
|
|
228
|
+
export AWS_ACCESS_KEY_ID=test
|
|
229
|
+
export AWS_SECRET_ACCESS_KEY=test
|
|
230
|
+
|
|
231
|
+
# Use with env-secrets
|
|
232
|
+
env-secrets aws -s local/myapp -r us-east-1 -- node app.js
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Can I use it with different environments?
|
|
236
|
+
|
|
237
|
+
Yes! Use environment-specific secrets:
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
# Development
|
|
241
|
+
env-secrets aws -s dev/myapp -r us-east-1 -- npm run dev
|
|
242
|
+
|
|
243
|
+
# Staging
|
|
244
|
+
env-secrets aws -s staging/myapp -r us-east-1 -- npm run dev
|
|
245
|
+
|
|
246
|
+
# Production
|
|
247
|
+
env-secrets aws -s prod/myapp -r us-east-1 -- npm start
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
## Integration Questions
|
|
251
|
+
|
|
252
|
+
### Can I use it with CI/CD?
|
|
253
|
+
|
|
254
|
+
Yes! Great for automated deployments:
|
|
255
|
+
|
|
256
|
+
```yaml
|
|
257
|
+
# GitHub Actions
|
|
258
|
+
- name: Deploy with secrets
|
|
259
|
+
run: env-secrets aws -s prod/app -r us-east-1 -- npm run deploy
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Can I use it with serverless?
|
|
263
|
+
|
|
264
|
+
Yes, but consider using AWS SDK directly for Lambda functions. For other serverless platforms, `env-secrets` works well.
|
|
265
|
+
|
|
266
|
+
### Can I use it with databases?
|
|
267
|
+
|
|
268
|
+
Yes! Perfect for database connections:
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
env-secrets aws -s db/config -r us-east-1 -- node app.js
|
|
272
|
+
|
|
273
|
+
# Your app can access DATABASE_URL, DB_USER, DB_PASSWORD, etc.
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
## Support Questions
|
|
277
|
+
|
|
278
|
+
### Where can I get help?
|
|
279
|
+
|
|
280
|
+
- **Documentation**: Check this site and the README
|
|
281
|
+
- **GitHub Issues**: [Report bugs or request features](https://github.com/markcallen/env-secrets/issues)
|
|
282
|
+
- **Debug Mode**: Use `DEBUG=env-secrets` for troubleshooting
|
|
283
|
+
|
|
284
|
+
### How do I report a bug?
|
|
285
|
+
|
|
286
|
+
Include:
|
|
287
|
+
|
|
288
|
+
- Error message and stack trace
|
|
289
|
+
- Debug output (`DEBUG=env-secrets`)
|
|
290
|
+
- AWS CLI version and configuration
|
|
291
|
+
- Node.js version
|
|
292
|
+
- Operating system
|
|
293
|
+
- Steps to reproduce
|
|
294
|
+
|
|
295
|
+
### Can I contribute?
|
|
296
|
+
|
|
297
|
+
Yes! Contributions are welcome:
|
|
298
|
+
|
|
299
|
+
- Fork the repository
|
|
300
|
+
- Create a feature branch
|
|
301
|
+
- Add tests for new functionality
|
|
302
|
+
- Submit a pull request
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: env-secrets
|
|
3
|
+
slug: /
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# env-secrets
|
|
7
|
+
|
|
8
|
+
`env-secrets` is a Node.js CLI that fetches secrets from a vault (starting with **AWS Secrets Manager**) and injects them into the **environment variables** of a child process you run.
|
|
9
|
+
|
|
10
|
+
**Highlights**
|
|
11
|
+
|
|
12
|
+
- Pull JSON secrets and expose each key as `ENV`.
|
|
13
|
+
- Run _any_ command with injected secrets: `env-secrets aws -s <name> -- <your command>`.
|
|
14
|
+
- Works globally (`npm i -g env-secrets`) or with `npx` per project.
|
|
15
|
+
- Debug-friendly (`DEBUG=env-secrets,...`).
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Install globally
|
|
21
|
+
npm install -g env-secrets
|
|
22
|
+
|
|
23
|
+
# Or use with npx
|
|
24
|
+
npx env-secrets aws -s my-secret -- node app.js
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Documentation
|
|
28
|
+
|
|
29
|
+
### Getting Started
|
|
30
|
+
|
|
31
|
+
- **[Overview](/overview)** - Learn about env-secrets
|
|
32
|
+
- **[Installation](/installation)** - How to install and set up
|
|
33
|
+
- **[CLI Reference](/cli-reference)** - Complete command reference
|
|
34
|
+
- **[Examples](/examples)** - Comprehensive usage examples
|
|
35
|
+
|
|
36
|
+
### Providers
|
|
37
|
+
|
|
38
|
+
- **[AWS Secrets Manager](/providers/aws-secrets-manager)** - Supported secret providers
|
|
39
|
+
|
|
40
|
+
### Tutorials
|
|
41
|
+
|
|
42
|
+
- **[Local Development](/tutorials/local-dev/quickstart)** - Step-by-step guides for local development
|
|
43
|
+
|
|
44
|
+
### Advanced Topics
|
|
45
|
+
|
|
46
|
+
- **[Advanced Usage](/advanced-usage)** - Complex patterns and integration scenarios
|
|
47
|
+
- **[Best Practices](/best-practices)** - Security and operational guidelines
|
|
48
|
+
- **[Production Deployment](/production-deployment)** - Production deployment strategies
|
|
49
|
+
|
|
50
|
+
### Security & Troubleshooting
|
|
51
|
+
|
|
52
|
+
- **[Security Considerations](/security)** - Security best practices and considerations
|
|
53
|
+
- **[Troubleshooting](/troubleshooting)** - Common issues and solutions
|
|
54
|
+
- **[FAQ](/faq)** - Frequently asked questions
|
|
55
|
+
|
|
56
|
+
> Source: [markcallen/env-secrets](https://github.com/markcallen/env-secrets)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Installation
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Node.js 18+
|
|
8
|
+
- (For AWS) AWS credentials via env vars, profile, or IAM role
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
### Global
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install -g env-secrets
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Per Project
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install env-secrets
|
|
22
|
+
# then
|
|
23
|
+
npx env-secrets --help
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Verify
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
env-secrets --help
|
|
30
|
+
```
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Overview
|
|
3
|
+
slug: /overview
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# env-secrets
|
|
7
|
+
|
|
8
|
+
`env-secrets` is a Node.js CLI that fetches secrets from a vault (starting with **AWS Secrets Manager**) and injects them into the **environment variables** of a child process you run.
|
|
9
|
+
|
|
10
|
+
**Highlights**
|
|
11
|
+
|
|
12
|
+
- Pull JSON secrets and expose each key as `ENV`.
|
|
13
|
+
- Run _any_ command with injected secrets: `env-secrets aws -s <name> -- <your command>`.
|
|
14
|
+
- Works globally (`npm i -g env-secrets`) or with `npx` per project.
|
|
15
|
+
- Debug-friendly (`DEBUG=env-secrets,...`).
|
|
16
|
+
|
|
17
|
+
> Source: [markcallen/env-secrets](https://github.com/markcallen/env-secrets)
|