Oracle Cloud Vault Integration
Overview
Oracle Cloud Vault is a managed service for storing and retrieving secrets (API keys, passwords, certificates). This guide shows how to:- Store your secrets in OCI Vault
- Retrieve them at runtime on your Oracle Cloud instance
- Remove the need to copy
.envfiles to your server
Prerequisites
- Oracle Cloud account with access to OCI Vault
- Oracle Cloud Infrastructure CLI (OCI CLI) installed on your server
- Existing Oracle Cloud compute instance running your EchOS deployment
Step 1: Create a Vault (One-time Setup)
Via OCI Console
- Log in to Oracle Cloud Console
- Navigate to Identity & Security → Vault
- Select your Compartment (or create a new one)
- Click Create Vault
- Name:
echos-vault - Click Create Vault
- Name:
Via OCI CLI (Optional)
Step 2: Create Secrets
Create a secret for each sensitive value:Via OCI Console
- Go to your vault → Secrets
- Click Create Secret
- Fill in:
- Name:
echos-telegram-bot-token - Secret Contents: Your Telegram bot token
- Encryption Key: Use the default key or create one
- Name:
- Repeat for:
echos-anthropic-api-keyechos-allowed-user-idsechos-openai-api-key(if used)
Via OCI CLI
Step 3: Set Up OCI CLI on Your Server
Install OCI CLI
Configure OCI CLI
Authenticate
The OCI CLI can authenticate using Instance Principal (recommended for compute instances):Step 4: Grant Access to Secrets (IAM Policy)
Create an IAM policy to allow your compute instance to read secrets:Via OCI Console
- Go to Identity & Security → Policies
- Select your compartment
- Click Create Policy
- Configure:
- Name:
echos-vault-access - Policy Versioning: Static
- Policy Statements:
- Name:
You may need to create a Dynamic Group for your compute instance: go to Identity & Security → Dynamic Groups and create:
All instances in compartment <YOUR_COMPARTMENT_NAME>.Via OCI CLI
Step 5: Create a Secret Retrieval Script
Create a script on your server to fetch secrets at startup:Step 6: Modify Docker Compose
Update your docker-compose.yml to use the secrets:Step 7: Update Deployment Script
Modifyscripts/deploy-fast.sh to:
- Remove the
.envfile upload - Add a step to fetch secrets on the server before starting
Step 8: Test the Setup
Updating Secrets
When you need to update a secret (e.g., rotate API key):Via OCI Console
- Go to Vault → Secrets
- Click on the secret
- Click Create New Version
- Enter the new value
Via OCI CLI
Troubleshooting
”Permission denied” when reading secrets
- Verify the IAM policy is correctly applied
- Check your dynamic group matches your instance
- Ensure the vault and secrets are in the same compartment as the policy
OCI CLI not authenticated
Secrets not loading
- Check the secrets directory permissions:
ls -la ~/echos/secrets/ - Verify
.envfile exists and has correct format - Check Docker logs:
docker compose logs echos
Security Benefits
- No .env files on server - Secrets are fetched at runtime
- Centralized management - Update secrets from OCI Console
- Audit logging - OCI Vault logs all secret access
- Encryption at rest - Secrets are encrypted with master keys
- No commit risk - Sensitive values never enter your git repo
Alternative: Simpler Approach
If Oracle Cloud Vault feels like overkill, consider this simpler alternative:Host Environment Variables
Set environment variables directly on the Oracle Cloud server:- ✅ No additional services needed
- ✅ Simple to set up
- ❌ Less secure than Vault
- ❌ Manual updates via SSH