Skip to content

Commit 392bae0

Browse files
committed
docs update
1 parent b8939b3 commit 392bae0

14 files changed

Lines changed: 501 additions & 530 deletions

File tree

docs/.vitepress/config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export default defineConfig({
2828
items: [
2929
{ text: 'Introduction', link: '/guide/' },
3030
{ text: 'Installation', link: '/guide/installation' },
31+
{ text: 'AWS Authentication', link: '/guide/aws-authentication' },
3132
{ text: 'Configuration', link: '/guide/configuration' },
3233
{ text: 'Quick Start', link: '/guide/quick-start' }
3334
]

docs/examples/index.md

Lines changed: 21 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,42 @@
11
# Examples
22

3-
This section provides practical examples of using Keep in real-world scenarios. These examples will help you understand how to integrate Keep into your workflow and get the most out of its features.
4-
53
## Available Examples
64

75
### [Laravel Integration](./laravel)
8-
Learn how to integrate Keep with your Laravel applications, including:
9-
- Service provider setup
10-
- Helper function usage
11-
- Caching strategies
12-
- Development workflow
6+
Integrate Keep with Laravel applications using the service provider and helper functions.
137

148
### [CI/CD Workflows](./ci-cd)
15-
Examples of using Keep in continuous integration and deployment:
16-
- GitHub Actions integration
17-
- Automated secret deployment
18-
- Environment promotion strategies
19-
- Security best practices
9+
Use Keep in GitHub Actions, GitLab CI, and other automation pipelines.
2010

2111
### [Multi-Environment Setup](./multi-environment)
22-
Best practices for organizing secrets across multiple environments:
23-
- Stage organization strategies
24-
- Vault selection guidelines
25-
- Secret promotion workflows
26-
- Team access patterns
12+
Organize secrets across development, staging, and production environments.
2713

2814
### [AWS Setup](./aws-setup)
29-
Complete guide to setting up Keep with AWS services:
30-
- IAM roles and permissions
31-
- SSM Parameter Store configuration
32-
- Secrets Manager setup
33-
- Cross-account access patterns
15+
Configure IAM roles, SSM Parameter Store, and Secrets Manager for Keep.
3416

35-
## Common Workflows
17+
## Quick Examples
3618

37-
### Development to Production Flow
19+
### Development to Production
3820
```bash
39-
# 1. Set up local development
21+
# Configure project
4022
keep configure
41-
keep vault:add local myapp
42-
keep set myapp:development API_KEY "dev-key-123"
23+
keep vault:add
24+
25+
# Set development secret
26+
keep set API_KEY "dev-key" --stage=development
4327

44-
# 2. Set up staging environment
45-
keep vault:add aws-ssm staging-vault
46-
keep copy myapp:development staging-vault:staging API_KEY
28+
# Copy to staging
29+
keep copy API_KEY --from=development --to=staging
4730

48-
# 3. Promote to production
49-
keep vault:add aws-secrets prod-vault
50-
keep copy staging-vault:staging prod-vault:production API_KEY
31+
# Promote to production
32+
keep copy API_KEY --from=staging --to=production
5133
```
5234

53-
### Template-Based Configuration
35+
### Using Templates
5436
```bash
55-
# Create template file
56-
echo "API_KEY={myapp:API_KEY}" > app.env.template
57-
58-
# Generate configuration
59-
keep template:validate app.env.template myapp:production
60-
keep template:merge app.env.template myapp:production > app.env
61-
```
37+
# Create template
38+
echo "API_KEY={ssm:API_KEY}" > .env.template
6239

63-
Each example includes complete code samples, configuration files, and step-by-step instructions to help you implement similar patterns in your own projects.
40+
# Generate config
41+
keep merge .env.template --stage=production --output=.env
42+
```

docs/guide/aws-authentication.md

Lines changed: 275 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,275 @@
1+
# AWS Authentication
2+
3+
Keep uses AWS services (SSM Parameter Store and Secrets Manager) to store your secrets. This page explains how to properly configure AWS authentication so Keep can access these vaults.
4+
5+
## The Secret Zero Problem
6+
7+
Before diving into solutions, it's worth understanding the "Secret Zero" problem: if Keep fetches secrets from AWS to generate your `.env` file, but AWS credentials are typically stored in `.env` files... we have a circular dependency. You need credentials to get credentials.
8+
9+
The solution is to keep AWS authentication separate from your application secrets.
10+
11+
## What NOT to Do
12+
13+
```env
14+
# .env file - DON'T DO THIS with Keep!
15+
AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
16+
AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
17+
DB_PASSWORD=my-secret-password
18+
API_KEY=sk_live_abc123
19+
```
20+
21+
Storing AWS credentials in `.env` defeats the purpose of Keep. You're storing the keys to the vault alongside the secrets themselves.
22+
23+
## Authentication Methods
24+
25+
### Development Environment
26+
27+
**Option 1: AWS CLI Configuration (Good)**
28+
29+
Use the AWS CLI's standard credential file:
30+
31+
```bash
32+
# Configure AWS CLI
33+
aws configure
34+
35+
# This creates ~/.aws/credentials
36+
[default]
37+
aws_access_key_id = AKIAIOSFODNN7EXAMPLE
38+
aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
39+
region = us-east-1
40+
```
41+
42+
Keep automatically uses these credentials. Your `.env` file stays clean:
43+
44+
```env
45+
# .env - generated by Keep, no AWS credentials!
46+
DB_PASSWORD=my-secret-password
47+
API_KEY=sk_live_abc123
48+
```
49+
50+
**Option 2: aws-vault (Better)**
51+
52+
[aws-vault](https://github.com/99designs/aws-vault) stores credentials encrypted in your OS keychain:
53+
54+
```bash
55+
# Install aws-vault
56+
brew install aws-vault # macOS
57+
# or download from GitHub releases
58+
59+
# Add your default AWS profile, or use a named profile
60+
aws-vault add default
61+
```
62+
63+
Edit your ~/.aws/config to set a default region and use aws-vault for credential_process:
64+
65+
```ini
66+
[default]
67+
region = us-east-1
68+
credential_process = aws-vault exec default --json --no-session
69+
```
70+
71+
Edit your ~/.aws/credentials and add the same credential_process:
72+
73+
```ini
74+
[default]
75+
credential_process = aws-vault exec default --json --no-session
76+
```
77+
78+
Now when you run Keep (or any AWS CLI command), it will use aws-vault to fetch temporary credentials automatically.
79+
80+
**Option 3: AWS SSO (Best for Teams)**
81+
82+
If your organization uses AWS SSO:
83+
84+
```bash
85+
# Configure SSO
86+
aws configure sso
87+
88+
# Login
89+
aws sso login --profile myproject
90+
91+
# Keep uses the SSO session automatically
92+
keep list --stage=development
93+
```
94+
95+
### Production Environment
96+
97+
**Option 1: EC2 Instance Roles (Best for AWS)**
98+
99+
When running on EC2, ECS, or Lambda, use IAM roles:
100+
101+
```bash
102+
# No credentials needed in your application!
103+
# The AWS SDK automatically uses the instance role
104+
105+
# In your deployment script:
106+
keep export --stage=production --output=.env
107+
php artisan config:cache
108+
```
109+
110+
Configure your EC2 instance role with appropriate IAM permissions for your vault type.
111+
112+
**Option 2: Non-AWS Servers**
113+
114+
For servers outside AWS, you have limited secure options:
115+
116+
```bash
117+
# Option A: Credentials file on server (secured with proper permissions)
118+
# /home/myapp/.aws/credentials (chmod 600)
119+
[default]
120+
aws_access_key_id = AKIAIOSFODNN7EXAMPLE
121+
aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
122+
123+
# Option B: Environment variables set during provisioning
124+
# For systemd services: /etc/systemd/system/myapp.service.d/override.conf
125+
[Service]
126+
Environment="AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE"
127+
Environment="AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
128+
129+
# For Docker: passed securely during container start
130+
docker run -e AWS_ACCESS_KEY_ID=... -e AWS_SECRET_ACCESS_KEY=... myapp
131+
132+
# For traditional setups: /etc/environment or user's ~/.bashrc
133+
```
134+
135+
## CI/CD Pipelines
136+
137+
**GitHub Actions**
138+
139+
Use OIDC (recommended) or secrets:
140+
141+
```yaml
142+
# .github/workflows/deploy.yml
143+
name: Deploy
144+
on: push
145+
146+
jobs:
147+
deploy:
148+
runs-on: ubuntu-latest
149+
permissions:
150+
id-token: write # for OIDC
151+
steps:
152+
- uses: aws-actions/configure-aws-credentials@v4
153+
with:
154+
role-to-assume: arn:aws:iam::123456789012:role/github-actions
155+
aws-region: us-east-1
156+
157+
- run: |
158+
vendor/bin/keep export --stage=production --output=.env
159+
# Deploy your application
160+
```
161+
162+
**GitLab CI**
163+
164+
```yaml
165+
# .gitlab-ci.yml
166+
deploy:
167+
script:
168+
# Using GitLab's AWS integration
169+
- vendor/bin/keep export --stage=production --output=.env
170+
id_tokens:
171+
AWS_TOKEN:
172+
aud: https://gitlab.com
173+
```
174+
175+
## Security Best Practices
176+
177+
### Never Do This
178+
179+
❌ Store AWS credentials in your repository
180+
❌ Put AWS credentials in `.env` files tracked by git
181+
❌ Use long-lived AWS access keys in production
182+
❌ Share AWS credentials between environments
183+
184+
### Always Do This
185+
186+
✅ Use temporary credentials when possible (aws-vault, SSO, instance roles)
187+
✅ Apply least-privilege IAM policies
188+
✅ Rotate credentials regularly
189+
✅ Use different credentials for each environment
190+
✅ Audit credential usage with CloudTrail
191+
192+
## Quick Decision Guide
193+
194+
| Environment | Hosting | Recommended Solution |
195+
|------------|---------|---------------------|
196+
| Development | Local | aws-vault or AWS SSO |
197+
| Production | EC2/ECS | Instance/Task IAM Roles |
198+
| Production | Lambda | Lambda Execution Role |
199+
| Production | Kubernetes (EKS) | IRSA (Service Accounts) |
200+
| Production | Non-AWS | ~/.aws/credentials (secured) |
201+
| CI/CD | GitHub Actions | OIDC with IAM Role |
202+
| CI/CD | GitLab | OIDC with IAM Role |
203+
| CI/CD | Other | Secure secret storage |
204+
205+
## IAM Permissions
206+
207+
After setting up authentication, you need to configure IAM permissions for the AWS services Keep will access:
208+
209+
- **For AWS SSM Parameter Store**: See [SSM IAM Permissions](/guide/vaults/aws-ssm#iam-permissions)
210+
- **For AWS Secrets Manager**: See [Secrets Manager IAM Permissions](/guide/vaults/aws-secrets-manager#iam-permissions)
211+
212+
Each vault type requires specific IAM permissions based on your usage pattern (read-only, read-write, or admin access).
213+
214+
## Laravel-Specific Considerations
215+
216+
When using Keep with Laravel:
217+
218+
1. **Don't cache config with AWS credentials**
219+
```php
220+
// config/aws.php - DON'T DO THIS
221+
'credentials' => [
222+
'key' => env('AWS_ACCESS_KEY_ID'),
223+
'secret' => env('AWS_SECRET_ACCESS_KEY'),
224+
]
225+
```
226+
227+
2. **Let the SDK find credentials automatically**
228+
```php
229+
// config/aws.php - DO THIS
230+
'credentials' => null, // SDK will use IAM role, ~/.aws/credentials, etc.
231+
```
232+
233+
3. **Generate .env before config:cache**
234+
```bash
235+
# deployment.sh
236+
keep export --stage=production --output=.env
237+
php artisan config:cache
238+
php artisan route:cache
239+
```
240+
241+
## Troubleshooting
242+
243+
**"Keep can't find AWS credentials"**
244+
245+
Check credential chain:
246+
```bash
247+
# 1. Environment variables
248+
env | grep AWS
249+
250+
# 2. Credentials file
251+
cat ~/.aws/credentials
252+
253+
# 3. Instance role (on EC2)
254+
curl http://169.254.169.254/latest/meta-data/iam/security-credentials/
255+
256+
# 4. Test with AWS CLI
257+
aws sts get-caller-identity
258+
```
259+
260+
**"Access denied when Keep tries to fetch secrets"**
261+
262+
Verify IAM permissions:
263+
```bash
264+
# Test SSM access
265+
aws ssm get-parameter --name /myapp/production/test
266+
267+
# Test Secrets Manager access
268+
aws secretsmanager get-secret-value --secret-id myapp/production/test
269+
```
270+
271+
## Summary
272+
273+
The Secret Zero problem is real, but solvable. By keeping AWS credentials **out** of your application configuration and using platform-native credential management, you maintain security while enabling Keep to manage your application secrets effectively.
274+
275+
Remember: Keep manages your application secrets, not your AWS credentials. Keep AWS credentials separate, secure, and platform-appropriate.

0 commit comments

Comments
 (0)