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,122 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Security Considerations
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Security Considerations
|
|
6
|
+
|
|
7
|
+
When using `env-secrets` in your applications, it's important to understand the security implications and follow best practices.
|
|
8
|
+
|
|
9
|
+
## Credential Management
|
|
10
|
+
|
|
11
|
+
`env-secrets` respects AWS credential precedence in the following order:
|
|
12
|
+
|
|
13
|
+
1. **Environment Variables** (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`)
|
|
14
|
+
2. **IAM Roles** (when running on EC2, ECS, or Lambda)
|
|
15
|
+
3. **AWS Profiles** (specified with `-p` flag)
|
|
16
|
+
|
|
17
|
+
### Best Practices
|
|
18
|
+
|
|
19
|
+
- **Use IAM Roles**: Prefer IAM roles over hardcoded credentials when possible
|
|
20
|
+
- **Least Privilege**: Grant only `secretsmanager:GetSecretValue` permission
|
|
21
|
+
- **Rotate Credentials**: Regularly rotate AWS access keys
|
|
22
|
+
- **Environment Isolation**: Use different AWS accounts/profiles for different environments
|
|
23
|
+
|
|
24
|
+
## Secret Exposure Prevention
|
|
25
|
+
|
|
26
|
+
### What env-secrets does NOT do:
|
|
27
|
+
|
|
28
|
+
- ❌ Store secrets locally on disk
|
|
29
|
+
- ❌ Log secrets to console or files
|
|
30
|
+
- ❌ Cache secrets in memory beyond the process lifetime
|
|
31
|
+
- ❌ Expose secrets in process lists
|
|
32
|
+
|
|
33
|
+
### What env-secrets does:
|
|
34
|
+
|
|
35
|
+
- ✅ Injects secrets only into the child process environment
|
|
36
|
+
- ✅ Cleans up environment variables when the process exits
|
|
37
|
+
- ✅ Uses AWS SDK's built-in security features
|
|
38
|
+
- ✅ Supports debug logging without exposing secret values
|
|
39
|
+
|
|
40
|
+
## Network Security
|
|
41
|
+
|
|
42
|
+
- **HTTPS Only**: All AWS API calls use HTTPS/TLS encryption
|
|
43
|
+
- **AWS SDK Security**: Leverages AWS SDK's built-in security features
|
|
44
|
+
- **No Local Storage**: No secrets are stored locally
|
|
45
|
+
|
|
46
|
+
## Audit Trail
|
|
47
|
+
|
|
48
|
+
All AWS Secrets Manager API calls are logged in AWS CloudTrail, providing:
|
|
49
|
+
|
|
50
|
+
- Access timestamps
|
|
51
|
+
- User/role information
|
|
52
|
+
- Secret names accessed
|
|
53
|
+
- API actions performed
|
|
54
|
+
|
|
55
|
+
## Environment Variable Security
|
|
56
|
+
|
|
57
|
+
### Child Process Isolation
|
|
58
|
+
|
|
59
|
+
Secrets are only injected into the specified child process:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Only the 'node app.js' process gets the secrets
|
|
63
|
+
env-secrets aws -s my-secret -r us-east-1 -- node app.js
|
|
64
|
+
|
|
65
|
+
# The parent shell environment remains unchanged
|
|
66
|
+
echo $DATABASE_URL # This will be empty
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Process Environment
|
|
70
|
+
|
|
71
|
+
The child process receives environment variables in the same way as if they were set normally:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# These are equivalent:
|
|
75
|
+
DATABASE_URL=postgres://... node app.js
|
|
76
|
+
|
|
77
|
+
env-secrets aws -s my-secret -r us-east-1 -- node app.js
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Production Security Checklist
|
|
81
|
+
|
|
82
|
+
Before deploying to production:
|
|
83
|
+
|
|
84
|
+
- [ ] Use IAM roles instead of access keys
|
|
85
|
+
- [ ] Implement least-privilege IAM policies
|
|
86
|
+
- [ ] Enable AWS CloudTrail logging
|
|
87
|
+
- [ ] Use separate AWS accounts for different environments
|
|
88
|
+
- [ ] Regularly rotate secrets in AWS Secrets Manager
|
|
89
|
+
- [ ] Monitor for unauthorized access attempts
|
|
90
|
+
- [ ] Use VPC endpoints for AWS Secrets Manager (if applicable)
|
|
91
|
+
|
|
92
|
+
## IAM Policy Example
|
|
93
|
+
|
|
94
|
+
Here's a minimal IAM policy for using env-secrets:
|
|
95
|
+
|
|
96
|
+
> **Note:** In the ARN below, replace `region` with your AWS region (e.g., `us-east-1`), and `account` with your AWS account ID. Also, replace `your-secret-name*` with the actual name or pattern of your secret(s).
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"Version": "2012-10-17",
|
|
101
|
+
"Statement": [
|
|
102
|
+
{
|
|
103
|
+
"Effect": "Allow",
|
|
104
|
+
"Action": "secretsmanager:GetSecretValue",
|
|
105
|
+
"Resource": "arn:aws:secretsmanager:region:account:secret:your-secret-name*"
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Debug Mode Security
|
|
112
|
+
|
|
113
|
+
When using debug mode, be aware that:
|
|
114
|
+
|
|
115
|
+
- Secret values are NOT logged
|
|
116
|
+
- Only metadata and API calls are logged
|
|
117
|
+
- Debug logs may contain secret names (but not values)
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
# Safe to use - no secret values are exposed
|
|
121
|
+
DEBUG=env-secrets env-secrets aws -s my-secret -r us-east-1 -- env
|
|
122
|
+
```
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Troubleshooting
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Troubleshooting
|
|
6
|
+
|
|
7
|
+
This guide helps you resolve common issues when using `env-secrets`.
|
|
8
|
+
|
|
9
|
+
## Common Issues
|
|
10
|
+
|
|
11
|
+
### "Unable to connect to AWS"
|
|
12
|
+
|
|
13
|
+
**Symptoms:**
|
|
14
|
+
|
|
15
|
+
- `ConfigError` or connection timeout errors
|
|
16
|
+
- "Unable to load credentials" messages
|
|
17
|
+
|
|
18
|
+
**Solutions:**
|
|
19
|
+
|
|
20
|
+
1. **Check AWS credentials:**
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Verify AWS CLI works
|
|
24
|
+
aws sts get-caller-identity
|
|
25
|
+
|
|
26
|
+
# Check environment variables
|
|
27
|
+
echo $AWS_ACCESS_KEY_ID
|
|
28
|
+
echo $AWS_SECRET_ACCESS_KEY
|
|
29
|
+
echo $AWS_DEFAULT_REGION
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
2. **Verify profile configuration:**
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# List available profiles
|
|
36
|
+
aws configure list-profiles
|
|
37
|
+
|
|
38
|
+
# Test with specific profile
|
|
39
|
+
aws sts get-caller-identity --profile your-profile
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
3. **Check network connectivity:**
|
|
43
|
+
```bash
|
|
44
|
+
# Test AWS API connectivity
|
|
45
|
+
aws secretsmanager list-secrets --region us-east-1
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### "Secret not found"
|
|
49
|
+
|
|
50
|
+
**Symptoms:**
|
|
51
|
+
|
|
52
|
+
- `ResourceNotFoundException` errors
|
|
53
|
+
- "Secret does not exist" messages
|
|
54
|
+
|
|
55
|
+
**Solutions:**
|
|
56
|
+
|
|
57
|
+
1. **Verify secret exists:**
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# List all secrets
|
|
61
|
+
aws secretsmanager list-secrets --region us-east-1
|
|
62
|
+
|
|
63
|
+
# Check specific secret
|
|
64
|
+
aws secretsmanager describe-secret --secret-id your-secret-name --region us-east-1
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
2. **Check secret name and region:**
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# Ensure correct region
|
|
71
|
+
env-secrets aws -s your-secret-name -r us-east-1 -- env
|
|
72
|
+
|
|
73
|
+
# Check for typos in secret name
|
|
74
|
+
aws secretsmanager list-secrets --region us-east-1 | grep your-secret-name
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
3. **Verify permissions:**
|
|
78
|
+
```bash
|
|
79
|
+
# Test secret access
|
|
80
|
+
aws secretsmanager get-secret-value --secret-id your-secret-name --region us-east-1
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### "ConfigError"
|
|
84
|
+
|
|
85
|
+
**Symptoms:**
|
|
86
|
+
|
|
87
|
+
- AWS SDK configuration errors
|
|
88
|
+
- Profile or credential issues
|
|
89
|
+
|
|
90
|
+
**Solutions:**
|
|
91
|
+
|
|
92
|
+
1. **Check AWS configuration:**
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# View current configuration
|
|
96
|
+
aws configure list
|
|
97
|
+
|
|
98
|
+
# Check credentials file
|
|
99
|
+
cat ~/.aws/credentials
|
|
100
|
+
|
|
101
|
+
# Check config file
|
|
102
|
+
cat ~/.aws/config
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
2. **Set up credentials properly:**
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# Configure with environment variables
|
|
109
|
+
export AWS_ACCESS_KEY_ID=your-access-key
|
|
110
|
+
export AWS_SECRET_ACCESS_KEY=your-secret-key
|
|
111
|
+
export AWS_DEFAULT_REGION=us-east-1
|
|
112
|
+
|
|
113
|
+
# Or configure with profile
|
|
114
|
+
aws configure --profile my-profile
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Environment variables not injected
|
|
118
|
+
|
|
119
|
+
**Symptoms:**
|
|
120
|
+
|
|
121
|
+
- Application doesn't receive expected environment variables
|
|
122
|
+
- `process.env.VARIABLE_NAME` returns `undefined`
|
|
123
|
+
|
|
124
|
+
**Solutions:**
|
|
125
|
+
|
|
126
|
+
1. **Verify secret format:**
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
# Check secret content
|
|
130
|
+
aws secretsmanager get-secret-value --secret-id your-secret-name --region us-east-1 --query SecretString
|
|
131
|
+
|
|
132
|
+
# Ensure it's valid JSON
|
|
133
|
+
aws secretsmanager get-secret-value --secret-id your-secret-name --region us-east-1 --query SecretString | jq .
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
2. **Test environment injection:**
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# Check what variables are injected
|
|
140
|
+
env-secrets aws -s your-secret-name -r us-east-1 -- env | grep -E "(DATABASE|API|SECRET)"
|
|
141
|
+
|
|
142
|
+
# Test with a simple command
|
|
143
|
+
env-secrets aws -s your-secret-name -r us-east-1 -- echo "DB_URL: $DATABASE_URL"
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
3. **Check for JSON parsing issues:**
|
|
147
|
+
```bash
|
|
148
|
+
# Enable debug mode to see parsing details
|
|
149
|
+
DEBUG=env-secrets env-secrets aws -s your-secret-name -r us-east-1 -- env
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Debug Mode
|
|
153
|
+
|
|
154
|
+
Enable debug logging to troubleshoot issues:
|
|
155
|
+
|
|
156
|
+
### Basic Debug
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
# Debug main application
|
|
160
|
+
DEBUG=env-secrets env-secrets aws -s my-secret -r us-east-1 -- env
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Detailed Debug
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
# Debug vault-specific operations
|
|
167
|
+
DEBUG=env-secrets,env-secrets:secretsmanager env-secrets aws -s my-secret -r us-east-1 -- env
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### AWS SDK Debug
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
# Debug AWS SDK operations
|
|
174
|
+
DEBUG=env-secrets,aws-sdk:* env-secrets aws -s my-secret -r us-east-1 -- env
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Error Messages Reference
|
|
178
|
+
|
|
179
|
+
| Error | Cause | Solution |
|
|
180
|
+
| ---------------------------- | ------------------------------ | --------------------------------- |
|
|
181
|
+
| `ConfigError` | AWS credentials not configured | Set up AWS credentials or profile |
|
|
182
|
+
| `ResourceNotFoundException` | Secret doesn't exist | Verify secret name and region |
|
|
183
|
+
| `AccessDeniedException` | Insufficient permissions | Check IAM policies |
|
|
184
|
+
| `ValidationException` | Invalid secret name | Use valid secret name format |
|
|
185
|
+
| `DecryptionFailureException` | Secret encryption issues | Contact AWS support |
|
|
186
|
+
|
|
187
|
+
## Performance Issues
|
|
188
|
+
|
|
189
|
+
### Slow Secret Retrieval
|
|
190
|
+
|
|
191
|
+
**Causes:**
|
|
192
|
+
|
|
193
|
+
- Network latency to AWS
|
|
194
|
+
- Large secret values
|
|
195
|
+
- Cold AWS SDK initialization
|
|
196
|
+
|
|
197
|
+
**Solutions:**
|
|
198
|
+
|
|
199
|
+
1. **Use closer AWS regions:**
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
# Choose region closest to your location
|
|
203
|
+
env-secrets aws -s my-secret -r us-west-2 -- node app.js
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
2. **Optimize secret size:**
|
|
207
|
+
|
|
208
|
+
- Keep secrets as small as possible
|
|
209
|
+
- Avoid storing large binary data in secrets
|
|
210
|
+
|
|
211
|
+
3. **Reuse AWS SDK instances:**
|
|
212
|
+
- The tool automatically reuses AWS SDK instances
|
|
213
|
+
- No additional configuration needed
|
|
214
|
+
|
|
215
|
+
## Getting Help
|
|
216
|
+
|
|
217
|
+
If you're still experiencing issues:
|
|
218
|
+
|
|
219
|
+
1. **Check the logs:** Enable debug mode and review the output
|
|
220
|
+
2. **Verify AWS setup:** Ensure AWS CLI works correctly
|
|
221
|
+
3. **Test with AWS CLI:** Try the same operations with AWS CLI directly
|
|
222
|
+
4. **Check permissions:** Verify IAM policies and roles
|
|
223
|
+
5. **Review documentation:** Check this troubleshooting guide and other docs
|
|
224
|
+
6. **Open an issue:** Create a GitHub issue with debug output and error details
|
|
225
|
+
|
|
226
|
+
### Creating a Good Bug Report
|
|
227
|
+
|
|
228
|
+
When reporting issues, include:
|
|
229
|
+
|
|
230
|
+
- Error message and stack trace
|
|
231
|
+
- Debug output (`DEBUG=env-secrets`)
|
|
232
|
+
- AWS CLI version and configuration
|
|
233
|
+
- Node.js version
|
|
234
|
+
- Operating system
|
|
235
|
+
- Steps to reproduce the issue
|
|
236
|
+
- Expected vs actual behavior
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Devcontainer + LocalStack
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Use LocalStack to develop without touching real AWS resources.
|
|
6
|
+
|
|
7
|
+
1. **Start LocalStack** (Docker or Helm)
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
docker compose up -d # or 'helm upgrade --install localstack ...'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
2. **Configure CLI**
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
aws configure --profile localstack
|
|
17
|
+
export AWS_PROFILE=localstack
|
|
18
|
+
export AWS_ENDPOINT_URL=http://localhost:4566
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
3. **Create a secret in LocalStack**
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
awslocal secretsmanager create-secret --name local/sample --secret-string '{"user":"dev","password":"dev"}'
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
4. **Run with env-secrets**
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
AWS_ENDPOINT_URL=http://localhost:4566 env-secrets aws -s local/sample -r us-east-1 -- env | grep -E '(user|password)'
|
|
31
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Docker Compose
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
You can combine `env-secrets` with Docker Compose for local workflows.
|
|
6
|
+
|
|
7
|
+
**Option A: Wrapper script**
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
env-secrets aws -s my/docker/secrets -r us-east-1 -- docker compose up
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Your Compose file can reference environment variables with `${VAR}` as usual.
|
|
14
|
+
|
|
15
|
+
**Option B: Inject into a "dotenv" file**
|
|
16
|
+
|
|
17
|
+
If your stack requires a `.env` file, generate it on the fly:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# generate .env without writing secrets to VCS
|
|
21
|
+
env-secrets aws -s my/docker/secrets -r us-east-1 -- sh -lc 'env | grep -E "^(DATABASE_URL|API_KEY)=" > .env && docker compose up'
|
|
22
|
+
```
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Next.js example
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Run Next.js with secrets injected at dev time.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
env-secrets aws -s nextjs/dev -r us-east-1 -- npm run dev
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Then read config in code via:
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
export const API_KEY = process.env.API_KEY!;
|
|
15
|
+
export const DATABASE_URL = process.env.DATABASE_URL!;
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
> For server components only—do **not** expose secrets to the browser.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Node, Python & Go examples
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## Node
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
env-secrets aws -s node/dev -r us-east-1 -- node server.js
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
// server.js
|
|
13
|
+
const apiKey = process.env.API_KEY;
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Python
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
env-secrets aws -s py/dev -r us-east-1 -- uvicorn app:app --reload
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```py
|
|
23
|
+
# app.py
|
|
24
|
+
import os
|
|
25
|
+
API_KEY = os.getenv("API_KEY")
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Go
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
env-secrets aws -s go/dev -r us-east-1 -- go run main.go
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```go
|
|
35
|
+
// main.go
|
|
36
|
+
package main
|
|
37
|
+
import ("fmt"; "os")
|
|
38
|
+
func main(){ fmt.Println(os.Getenv("API_KEY")) }
|
|
39
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Local dev quickstart
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
This tutorial shows how to fetch a JSON secret and run your app locally with environment variables injected.
|
|
6
|
+
|
|
7
|
+
1. **Create a JSON secret**
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
aws secretsmanager create-secret --name my/local/app --region us-east-1 --secret-string '{"DATABASE_URL":"postgres://user:pass@localhost:5432/db","API_KEY":"abc123"}'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
2. **Start your app with `env-secrets`**
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
env-secrets aws -s my/local/app -r us-east-1 -- npm run dev
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
3. **Confirm variables are present**
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
env | grep -E 'DATABASE_URL|API_KEY'
|
|
23
|
+
```
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Config } from '@docusaurus/types';
|
|
2
|
+
import { themes as prismThemes } from 'prism-react-renderer';
|
|
3
|
+
|
|
4
|
+
const config: Config = {
|
|
5
|
+
title: 'env-secrets',
|
|
6
|
+
tagline:
|
|
7
|
+
'Fetch secrets from your vault — run any app with env vars injected.',
|
|
8
|
+
url: 'https://markcallen.github.io',
|
|
9
|
+
baseUrl: '/env-secrets/',
|
|
10
|
+
favicon: 'img/favicon.ico',
|
|
11
|
+
organizationName: 'markcallen',
|
|
12
|
+
projectName: 'env-secrets',
|
|
13
|
+
onBrokenLinks: 'throw',
|
|
14
|
+
onBrokenMarkdownLinks: 'warn',
|
|
15
|
+
i18n: { defaultLocale: 'en', locales: ['en'] },
|
|
16
|
+
presets: [
|
|
17
|
+
[
|
|
18
|
+
'classic',
|
|
19
|
+
{
|
|
20
|
+
docs: {
|
|
21
|
+
sidebarPath: require.resolve('./sidebars.ts'),
|
|
22
|
+
routeBasePath: '/',
|
|
23
|
+
editUrl:
|
|
24
|
+
'https://github.com/markcallen/env-secrets/edit/main/website/docs/',
|
|
25
|
+
showLastUpdateAuthor: true,
|
|
26
|
+
showLastUpdateTime: true
|
|
27
|
+
},
|
|
28
|
+
blog: false,
|
|
29
|
+
theme: { customCss: require.resolve('./src/css/custom.css') }
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
],
|
|
33
|
+
themeConfig: {
|
|
34
|
+
image: 'img/social-card.png',
|
|
35
|
+
navbar: {
|
|
36
|
+
title: 'env-secrets',
|
|
37
|
+
logo: { alt: 'env-secrets logo', src: 'img/env-secrets.png' },
|
|
38
|
+
items: [
|
|
39
|
+
{
|
|
40
|
+
type: 'docSidebar',
|
|
41
|
+
sidebarId: 'docs',
|
|
42
|
+
position: 'left',
|
|
43
|
+
label: 'Docs'
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
href: 'https://github.com/markcallen/env-secrets',
|
|
47
|
+
label: 'GitHub',
|
|
48
|
+
position: 'right'
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
footer: {
|
|
53
|
+
style: 'dark',
|
|
54
|
+
links: [
|
|
55
|
+
{
|
|
56
|
+
title: 'Docs',
|
|
57
|
+
items: [
|
|
58
|
+
{ label: 'Overview', to: '/overview' },
|
|
59
|
+
{ label: 'CLI', to: '/cli-reference' }
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
title: 'Community',
|
|
64
|
+
items: [
|
|
65
|
+
{
|
|
66
|
+
label: 'Issues',
|
|
67
|
+
href: 'https://github.com/markcallen/env-secrets/issues'
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
title: 'More',
|
|
73
|
+
items: [
|
|
74
|
+
{
|
|
75
|
+
label: 'GitHub',
|
|
76
|
+
href: 'https://github.com/markcallen/env-secrets'
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
copyright: `© ${new Date().getFullYear()} Mark C Allen.`
|
|
82
|
+
},
|
|
83
|
+
prism: {
|
|
84
|
+
theme: prismThemes.github,
|
|
85
|
+
darkTheme: prismThemes.dracula
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
export default config;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "env-secrets-website",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"docusaurus": "docusaurus",
|
|
7
|
+
"start": "docusaurus start",
|
|
8
|
+
"build": "docusaurus build",
|
|
9
|
+
"serve": "docusaurus serve",
|
|
10
|
+
"clear": "docusaurus clear"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@docusaurus/core": "^3.8.1",
|
|
14
|
+
"@docusaurus/preset-classic": "^3.8.1",
|
|
15
|
+
"@docusaurus/theme-classic": "^3.8.1",
|
|
16
|
+
"@mdx-js/react": "^3.0.1",
|
|
17
|
+
"clsx": "^2.1.1",
|
|
18
|
+
"react": "^18.3.1",
|
|
19
|
+
"react-dom": "^18.3.1"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { SidebarsConfig } from '@docusaurus/plugin-content-docs';
|
|
2
|
+
const sidebars: SidebarsConfig = {
|
|
3
|
+
docs: [
|
|
4
|
+
{ type: 'doc', id: 'index' },
|
|
5
|
+
{ type: 'doc', id: 'overview' },
|
|
6
|
+
{ type: 'doc', id: 'installation' },
|
|
7
|
+
{
|
|
8
|
+
type: 'category',
|
|
9
|
+
label: 'Providers',
|
|
10
|
+
items: ['providers/aws-secrets-manager']
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
type: 'category',
|
|
14
|
+
label: 'Local Development Tutorials',
|
|
15
|
+
items: [
|
|
16
|
+
'tutorials/local-dev/quickstart',
|
|
17
|
+
'tutorials/local-dev/docker-compose',
|
|
18
|
+
'tutorials/local-dev/nextjs',
|
|
19
|
+
'tutorials/local-dev/node-python-go',
|
|
20
|
+
'tutorials/local-dev/devcontainer-localstack'
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
{ type: 'doc', id: 'cli-reference' },
|
|
24
|
+
{ type: 'doc', id: 'examples' },
|
|
25
|
+
{ type: 'doc', id: 'advanced-usage' },
|
|
26
|
+
{ type: 'doc', id: 'best-practices' },
|
|
27
|
+
{ type: 'doc', id: 'production-deployment' },
|
|
28
|
+
{ type: 'doc', id: 'security' },
|
|
29
|
+
{ type: 'doc', id: 'troubleshooting' },
|
|
30
|
+
{ type: 'doc', id: 'faq' }
|
|
31
|
+
]
|
|
32
|
+
};
|
|
33
|
+
export default sidebars;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/* custom styles here */
|
|
Binary file
|
|
File without changes
|