Vault Transit Encryption-as-a-Service Design Prompt
Design a Vault Transit setup that encrypts application data without the app ever holding a key, including key rotation, rewrap strategy, and envelope encryption for large payloads.
- Target user
- Application and platform engineers adding encryption to a service
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior application-security engineer who has moved several teams off homegrown crypto onto Vault's Transit engine, and who knows the difference between encrypting a column and encrypting a blob. I will provide: - What data needs encrypting (fields, documents, files), typical and maximum sizes, and volume per second - Where it is stored (Postgres, MySQL, S3, MongoDB) and the language/SDK of the calling service - Requirements: searchability, deterministic matching, per-tenant isolation, regulatory constraints - Latency budget and whether the service can tolerate a Vault round trip on the hot path Your job: 1. **Choose the key design.** Recommend key type (`aes256-gcm96` default, `chacha20-poly1305`, or an asymmetric type such as `rsa-2048`/`ecdsa-p256`/`ed25519` if signing is needed) and key granularity — one key per application, per data classification, or per tenant — with the blast-radius and operational-cost tradeoff spelled out. Show `vault write -f transit/keys/<name> type=... auto_rotate_period=...`. 2. **Decide direct encrypt vs envelope encryption.** For small fields, call `transit/encrypt/<key>` with base64 plaintext and store the returned `vault:v1:...` ciphertext, which carries its own key-version prefix. For large objects, use `transit/datakey/plaintext/<key>` to get a data key, encrypt locally with AES-GCM, store only the wrapped key alongside the object, and zeroize the plaintext data key. Give a concrete rule for the size threshold and explain the bandwidth and latency reasons. 3. **Handle the searchability question honestly.** If I need equality lookups, explain `convergent_encryption` with `derived = true` and a per-record context, what it leaks (equal plaintexts produce equal ciphertexts), and safer alternatives such as a blind index over an HMAC from `transit/hmac/<key>`. If I do not need it, say so and keep encryption non-deterministic. 4. **Design rotation and rewrap.** Explain that `transit/keys/<name>/rotate` creates a new version, that existing ciphertext stays decryptable, and that `min_decryption_version` is the actual lever for retiring old key material. Give the rewrap workflow — a batched job calling `transit/rewrap/<name>` (using `batch_input` for throughput) that walks stored ciphertext, writes it back, and only then raises `min_decryption_version`. Include restartability, progress tracking, rate limiting, and how to detect rows the job missed. 5. **Write the least-privilege policy.** Produce HCL granting `update` on `transit/encrypt/<key>` and `transit/decrypt/<key>` only, and show why a service that only writes data should not get decrypt at all. Restrict rotation and rewrap to a separate operator or job identity, and never grant `delete` on `transit/keys/*` to an application. Note `deletion_allowed` defaults to false for a reason. 6. **Plan performance and resilience.** Cover batch endpoints for bulk operations, `transit/cache-config` for key caching, client-side connection reuse, expected latency per call, and what the service does when Vault is unreachable or sealed — fail closed on decrypt, queue or reject on encrypt, and never fall back to storing plaintext. If reads must survive a Vault outage, discuss envelope encryption with a short-lived cached data key and its tradeoffs. 7. **Cover key lifecycle and recovery.** Address backup/restore expectations (`exportable` and `allow_plaintext_backup` are off by default — explain the risk before ever enabling them), what happens to ciphertext if the key is lost, and the Enterprise options for stronger custody: managed keys backed by a cloud KMS or HSM, and seal wrap for FIPS-oriented deployments. 8. **Migration path.** Give a phased plan to encrypt existing data: add the ciphertext column, dual-write, backfill in batches, verify decryption round-trips, cut reads over, then drop the plaintext column and confirm it is gone from backups and replicas. Output as: (a) key design and CLI to create it, (b) encrypt/decrypt call examples in my language, (c) the rotation and rewrap runbook, (d) the Vault policy HCL, (e) performance and failure-mode notes, (f) the backfill migration plan. Never let the application hold raw key material, never enable exportable keys to work around a design problem, and treat any fallback that writes plaintext during a Vault outage as unacceptable.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Why this prompt works
Transit’s whole value is that the application never holds a key, and the designs that fail are the ones that erode that property one convenience at a time — an exportable key to make a migration easier, a plaintext backup to simplify DR, a cached key that outlives its purpose. The prompt front-loads key design and granularity with the blast-radius tradeoff stated explicitly, because key-per-tenant versus key-per-application is the decision that determines what a single compromise costs and it is very expensive to change once ciphertext exists in the shape of the original choice.
The direct-encrypt versus envelope-encryption split is included because it is where naive implementations fall over at scale rather than at design review. Round-tripping a large object through transit/encrypt works fine in testing and becomes a bandwidth and latency problem in production, so the prompt demands a concrete size threshold and the reasoning behind it, plus the discipline of zeroizing the plaintext data key after local encryption. The searchability question gets the same treatment: convergent encryption is a real option with a real leak — equal plaintexts produce equal ciphertexts — and the prompt requires that to be said plainly alongside the blind-index alternative rather than offered as a free feature.
Rotation is the section that most often goes missing entirely, and it is the one with a trapdoor. Rotating a Transit key is cheap and does nothing on its own: old ciphertext stays decryptable, and min_decryption_version is the lever that actually retires key material. Requiring a batched, restartable, rate-limited rewrap job with progress tracking and a way to detect missed rows — and raising min_decryption_version only afterwards — is what stops a well-intentioned rotation from silently orphaning the records the job never reached.
Related prompts
-
HashiCorp Vault Dynamic Secrets Design Prompt
Design short-lived, dynamic secrets in HashiCorp Vault — database, cloud, and PKI engines — with auth methods, lease/TTL strategy, and least-privilege policies that replace long-lived static credentials.
-
Vault Least-Privilege Policy Design Prompt
Turn a set of plain-English access requirements into reviewed HashiCorp Vault policy HCL that grants the minimum capabilities on the minimum paths, with templated paths for multi-tenant scoping.
-
Kubernetes Secret Encryption-at-Rest with KMS Prompt
Design encryption at rest for Kubernetes Secrets in etcd using a KMS provider, with envelope encryption, key rotation, and verification that existing secrets get re-encrypted.
-
Vault Agent Auto-Auth & Secret Templating Prompt
Design a Vault Agent deployment that authenticates workloads automatically, caches and renews tokens, and renders secrets into config files without ever hardcoding credentials.
More HashiCorp Vault prompts & error guides
Browse every HashiCorp Vault prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.