API keys should never be committed to Git! If leaked, immediately invalidate and reissue the
keys.
Common API Keys
These are frequently used external service API keys in Sonamu.AWS (S3 Storage)
.env
OpenAI
.env
Optional External Service Integrations
Sonamu can integrate with various external services. Below are environment variable examples for commonly used services.These services are not part of Sonamu’s default configuration. Add them only when needed for your
project.
- Stripe
- SendGrid
Environment-Specific Key Management
- Development
- Staging
- Production
.env.development
- Uses test mode keys
- No or minimal charges
- Limited permissions
Creating AWS IAM User
Access IAM Console
Go to AWS IAM Console
Create User
- Users → Add users 2. User name:
sonamu-s3-user3. Access type: Select Programmatic access
Set Permissions
Option 1: Attach Existing PolicyOption 2: Custom Policy (recommended)
sonamu-s3-policy.json
Issue Access Keys
After user creation completes:
- Access key ID:
your-aws-access-key-id - Secret access key:
your-aws-secret-access-key
The secret access key is displayed only once! Save it to a secure location immediately.
Add to .env File
Issuing OpenAI API Key
Access OpenAI Platform
Log in to OpenAI API Platform
Create API Key
- API keys → Create new secret key 2. Name:
sonamu-production3. Permissions: All or Restricted (recommended)
Set Usage Limits
Settings → Billing → Set Usage limits
Save Key
Security Best Practices
Key Rotation
Key Rotation
Regular Key Replacement
Recommended Frequency:- Production: Every 3 months
- Staging: Every 6 months
- Development: Yearly or as needed
Rotation Procedure
1
Create New Key
Create a new key while keeping the existing one active.
2
Deploy New Key
3
Monitor
Verify it works without errors for 24 hours
4
Delete Old Key
Deactivate/delete the old key if no issues
To perform key rotation without downtime, use a blue-green approach that maintains both new and old keys simultaneously.
Key Leak Response
Key Leak Response
Environment Variable Encryption
Environment Variable Encryption
Key Usage Monitoring
AWS CloudWatch
OpenAI Usage Alerts
Test Environment Key Management
Troubleshooting
OpenAI Rate Limit
OpenAI Rate Limit
Symptoms:Causes:
- API request limit exceeded (RPM, TPM)
S3 403 Forbidden
S3 403 Forbidden
Symptoms:Causes:
- IAM policy missing required permissions
- Blocked by bucket policy
Next Steps
.env Setup
Learn environment variable basics
Database Credentials
Safely manage DB connection information
Storage Configuration
Configure S3 storage
Session Settings
Check session and security settings