Prompt
I need a secure way to keep embeddings and prompts separated by environment
Latest observation
A good secure pattern is to separate by deployment boundary, not just by code path. In practice, that means each environment gets its own isolated resources for:
- prompts
- embeddings/vector indexes
- secrets
- service accounts / IAM roles
- storage buckets / databases
Recommended approach
1) Use separate environments with hard isolation
Create distinct:
devstagingprod
And for each one, use:
- separate cloud project/account/subscription if possible
- separate vector store/index
- separate prompt repository or config namespace
- separate secret store paths
- separate KMS keys
- separate API credentials
This prevents accidental cross-environment reads.
2) Store prompts and embeddings separately
Treat them as different classes of data:
Prompts
- store in a versioned config system or repo
- deploy them per environment
- keep them immutable per release
- validate before rollout
Embeddings
- store in a dedicated vector DB/index per environment
- never reuse embeddings across envs unless the underlying data is identical and approved
- namespace them by environment, e.g.
prod_docs,staging_docs
3) Enforce environment-specific access control
Use IAM or RBAC so:
- prod app can only read prod prompts and prod embeddings
- staging app can only read staging resources
- humans should not use shared credentials across envs
Prefer:
- workload identity / managed identity
- short-lived tokens
- least-privilege roles
4) Keep secrets separate
Each environment should have its own:
- LLM API key
- vector DB credentials
- encryption keys
- database passwords
Store them in:
- AWS Secrets Manager / Parameter Store
- Azure Key Vault
- GCP Secret Manager
- HashiCorp Vault
Do not copy prod secrets into non-prod.
5) Encrypt at rest with env-specific keys
Use a different KMS key per environment so even if storage is misconfigured, data remains isolated.
Example:
kms-devkms-stagingkms-prod
6) Add runtime guards
In application code, make the environment explicit and fail closed.
Example checks:
- environment variable
APP_ENV=prod - prompt loader only reads
prompts/prod/* - vector client only connects to
vectordb-prod - startup validation ensures env names match
If there’s a mismatch, stop the app from starting.
7) Use separate CI/CD deployment channels
Promote artifacts rather than sharing runtime state:
- build once
- deploy to dev
- promote to staging
- approve for prod
Prompts and embedding pipelines should be environment-aware, but the data stores should still be separate.
Good security model
A strong setup looks like this:
- Repo: version-controlled prompts
- Embedding pipeline: generates embeddings per environment
- Vector DB: separate index per environment
- Secrets manager: separate secret namespace per environment
- IAM: one service identity per environment
- KMS: one key per environment
- Network: prod access restricted to prod workloads only
Example naming convention
myapp-dev-promptsmyapp-staging-promptsmyapp-prod-promptsmyapp-dev-vectorsmyapp-prod-vectors
If you want the simplest secure rule
Never allow one environment to read another environment’s prompts, embeddings, or secrets.
Enforce this with separate storage, separate identities, and separate encryption keys.
If you want, I can sketch:
- a reference architecture,
- a Terraform/IaC layout, or
- a code pattern for loading prompts and embeddings safely by environment.