Skip to main content

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 .env files 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

  1. Log in to Oracle Cloud Console
  2. Navigate to Identity & SecurityVault
  3. Select your Compartment (or create a new one)
  4. Click Create Vault
    • Name: echos-vault
    • Click Create Vault

Via OCI CLI (Optional)


Step 2: Create Secrets

Create a secret for each sensitive value:

Via OCI Console

  1. Go to your vault → Secrets
  2. Click Create Secret
  3. Fill in:
    • Name: echos-telegram-bot-token
    • Secret Contents: Your Telegram bot token
    • Encryption Key: Use the default key or create one
  4. Repeat for:
    • echos-anthropic-api-key
    • echos-allowed-user-ids
    • echos-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

  1. Go to Identity & SecurityPolicies
  2. Select your compartment
  3. Click Create Policy
  4. Configure:
    • Name: echos-vault-access
    • Policy Versioning: Static
    • Policy Statements:
You may need to create a Dynamic Group for your compute instance: go to Identity & SecurityDynamic 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

Modify scripts/deploy-fast.sh to:
  1. Remove the .env file upload
  2. 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

  1. Go to VaultSecrets
  2. Click on the secret
  3. Click Create New Version
  4. Enter the new value

Via OCI CLI

After updating, restart your container:

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 .env file exists and has correct format
  • Check Docker logs: docker compose logs echos

Security Benefits

  1. No .env files on server - Secrets are fetched at runtime
  2. Centralized management - Update secrets from OCI Console
  3. Audit logging - OCI Vault logs all secret access
  4. Encryption at rest - Secrets are encrypted with master keys
  5. 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:
This approach:
  • ✅ No additional services needed
  • ✅ Simple to set up
  • ❌ Less secure than Vault
  • ❌ Manual updates via SSH

References