Canonical Charmed MongoDB Encryption at Rest Guide
Published 2026-11-24Category: Guides
Canonical's Charmed MongoDB encryption at rest uses a dual-key hierarchy with HashiCorp Vault or local storage. Must be configured before initial
Table of contents
- 1.Introduction
- 2.Key Points & Parameter Comparison
- 3.Deep Dive & Operational Details
- 3.1.Dual-Layer Key Architecture & Instance Isolation
- 3.2.HashiCorp Vault Integration Full Workflow
- 3.3.Local Key Management Limits & Emergency Plans
- 4.Scenario-Based Selection & Pitfall Checklist
- 5.FAQ
- 6.Sources & References

Introduction
Canonical’s official blog published a deep technical article on 2026-11-23 detailing Charmed MongoDB’s encryption at rest architecture, deployment constraints, and key management practices. The core takeaway: encryption is an immutable deployment-time decision that cannot be toggled at runtime. It employs a dual-layer key hierarchy — a master key encrypting a key database — with the master key generated locally and stored encrypted. Two master key storage paths are provided: HashiCorp Vault or a local Base64 file. The article repeatedly emphasizes “lost key equals lost data,” making it essential reading for production operations teams with strong data compliance and disk-theft protection requirements. Evaluate full key lifecycle management capabilities before committing.
Key Points & Parameter Comparison
| Dimension | Key Constraints & Configuration Points | Risk Warning |
|---|---|---|
| Activation Timing | Must be configured before initial deployment, effective before database first starts | Runtime config changes cause service restart failure; irreversible operation |
| Key Hierarchy | Dual-layer: instance-level master key → encrypted key database (contains single data encryption key) | Master key loss = full data unrecoverable; no backdoor |
| Master Key Storage | 1) HashiCorp Vault 2) Local Base64 file | Local mode unsuitable for multi-node clusters; Vault requires pre-deployment and policy config |
| Deployment Config | Must set encryption-at-rest, encryption-key-manager, and related config items |
Parameter typos cause deployment failure with no rollback |
| Compliance Value | Meets disk-level theft protection, regulatory compliance (GDPR, HIPAA, etc.) | Only protects data at rest; transport layer still requires separate TLS configuration |
Deep Dive & Operational Details
Dual-Layer Key Architecture & Instance Isolation
Charmed MongoDB generates an independent master key for each database instance. The master key encrypts a special “key database” that internally stores a single data encryption key (DEK). This design allows key rotation by re-encrypting only the DEK rather than all data, but also means that if the master key is leaked or lost, all data files for that instance become instantly unusable. The master key exists in Base64-encoded form. In local storage mode, the Operator writes a plaintext file in the unit directory — equivalent to running unencrypted if the physical machine is stolen. Production environments therefore mandate integration with an external KMS.
HashiCorp Vault Integration Full Workflow
Vault integration requires four pre-provisioning steps:
- Enable Transit engine:
vault secrets enable transit - Create encryption key ring:
vault write -f transit/keys/mongodb-key-ring - Write policy allowing
transit/encrypt/mongodb-key-ringandtransit/decrypt/mongodb-key-ring - Create AppRole, bind policy, obtain
role_idandsecret_id
During deployment, pass via Juju config: vault-url, vault-auth-method=approle, vault-role-id, vault-secret-id, vault-transit-path=transit, and vault-key-name=mongodb-key-ring. On startup, the Operator automatically requests master key ciphertext generation from Vault and writes it to disk; subsequent restarts follow the decryption flow. The source material does not disclose Vault version requirements, network latency impact on startup time, or automated key rotation cadence.
Local Key Management Limits & Emergency Plans
In local mode, setting encryption-key-manager=local causes the Operator to generate the master key and write it to the unit sandbox. The material explicitly states: this mode is only suitable for single-node development/testing and does not support multi-node replica sets, because each node’s differing master key prevents syncing encrypted data files. Operations must manually back up the master key file (source does not provide absolute path) and store offline in HSM or paper media. If the master key file is corrupted, the material provides no recovery tools or offline decryption means — only the warning “no one can recover the data.”
Scenario-Based Selection & Pitfall Checklist
- Production Cluster with Strong Compliance: Must choose Vault mode. Pre-deploy HA Vault cluster and test network connectivity. Harden all encryption parameters in Juju Bundle to avoid manual deployment omissions.
- Single-Node Dev/Test Environment:
localmode can quickly validate encryption functionality, but cannot be directly migrated to production — requires redeployment with Vault switch. - Key Rotation Drills: Pre-production in Staging, simulate Vault key version rollover (
vault write transit/keys/mongodb-key-ring/rotate), observe whether MongoDB instances automatically detect new ciphertext version. Material does not specify if restart is required. - Backup Strategy Adjustment: Encrypted data file backups no longer need additional encryption, but must synchronously back up master key ciphertext (in Vault mode, the Vault storage backend). Both are indispensable.
- Core Pitfall: Never attempt to enable
encryption-at-rest=trueon an existing unencrypted cluster. Material explicitly states this causes service deadlock with no rollback. The only path is rebuilding the cluster and migrating data logically.
FAQ
Can an existing unencrypted Charmed MongoDB cluster enable encryption at rest in place?
No. The material explicitly states: encryption at rest must be configured before initial deployment as an immutable database state. Runtime config changes cause service restart failure. The only viable approach is deploying a new encrypted cluster and migrating data via logical backup.
When using HashiCorp Vault mode, does the MongoDB instance contact Vault on every startup?
The material describes the Operator requesting master key ciphertext generation from Vault at startup and writing it to disk, with subsequent restarts following a decryption flow. However, it does not clarify whether every startup requires online Vault access, nor the fallback strategy when Vault is unavailable. Validate startup dependencies through offline testing before deployment.
In local key mode, what is the exact master key file path and permissions?
The source does not disclose absolute path or file permission details, only mentioning “stored locally in a Base64-encoded file.” Operations must juju ssh into the unit post-deployment to locate it, or reference the Charmed MongoDB Operator source code. Do not assume default paths.
Sources & References
- Ubuntu Blog: Automating encryption at rest with Canonical’s Charmed MongoDB (2026-11-23)
Spotted outdated pricing, stock, or expired coupons?See methodology & report an update →

