DocumentDB Cluster, Encrypted and Auditable
A cluster whose two dangerous AWS defaults are inverted: storage encryption is hard-coded on because it cannot be added later, and the master password is never an input - Secrets Manager generates it, so it never reaches the state file.
Verification
Static-verifiedPassed: validated and lint-clean (provider-schema-validated for AWS/Azure/GCP; Terraform-language lint elsewhere).
Conformance
- Static validation (fmt · validate · tflint)
- Security scan pending (Checkov)
- Plan tests (mocked: validation rules · outputs)
Provenance
- SHA-256 checksum
- Signature (pending)
Functional
- Live test pending (no cloud run yet)
Last verified 2026-09-12 · how we verify
Use it from the registry
terraform · opentofumodule "documentdb" {
source = "www.iac-bazaar.com/iac-bazaar/aws-documentdb/aws"
version = "1.0.0"
}Needs a registry token from /account/tokens. The module itself is free; the account is what identifies you. Full setup: registry docs.
Inputs & outputs
Create a free account to read this module's contract
The declared contract - every input name, type, default and description, plus every output - is shown to signed-in accounts, not to anonymous visitors.
A free account sees the contract of every module in the catalogue. There is no subscription and nothing to buy - the modules are free to download, and they run under Vizier.
Documentation
aws-documentdb
An Amazon DocumentDB cluster, its instances, subnet group and parameter group.
Works with Terraform and OpenTofu (>= 1.6), AWS provider
>= 6.0, < 7.0.
Two AWS defaults are wrong here, and this module inverts both.
storage_encrypteddefaults to false. A cluster written the obvious way is unencrypted at rest, and it cannot be encrypted afterwards - the only route is a snapshot restored into a new cluster, with the downtime that implies. This module hard-codes it on; it is not a variableskip_final_snapshotis how adestroytakes the data with it. It defaults off here, and a precondition refuses the one combination that leaves nothing behind:skip_final_snapshoton anddeletion_protectionoff
The master password is not an input. manage_master_user_password hands it
to Secrets Manager, which generates and rotates it. A password variable, however
carefully marked sensitive, is written into the state file in plain text, and
the state file is copied to wherever your backend lives. The secret's ARN is an
output.
Other defaults worth knowing:
audit_logson. Off, the question "what did that credential touch?" has no answer at all- Two instances, with
promotion_tierset from the index so a failover is predictable rather than whichever replica answers first - A precondition requires two or more subnets: a single-AZ cluster cannot fail over, and nothing in the AWS API says so at apply time
master_usernameis validated againstadminandroot, which DocumentDB reserves and rejects lateallow_major_version_upgradeoff: a major engine change is a migration, not a plan
Verification
Static validation runs tofu fmt, init, validate, tflint and checkov.
This module has not yet had a live test, so it is published as statically
validated with its live test pending and does not carry the live-tested mark.
Usage code & full reference need an account
The complete copy-paste usage, the full input/output reference, and operational notes are free with an account - shown here and bundled in the download. Sign in and this section fills in.
- Usage
Related modules
aws-aurora
Aurora PostgreSQL/MySQL cluster with instances, parameter groups, Serverless v2 scaling, and enhanced monitoring.
aws-dynamodb-table
DynamoDB table with GSIs/LSIs, TTL, streams, autoscaling or on-demand, and point-in-time recovery.
aws-elasticache-redis
A cluster-mode-disabled ElastiCache Redis/Valkey cache with encryption at rest and in transit both on, no public exposure, and the subnet group and security group created for you.
aws-memorydb
Durable Redis-compatible storage with an ACL holding real users, authenticated through IAM. MemoryDB ships an ACL named open-access that accepts any connection reaching the port with no credentials; this module will not use it.
aws-opensearch
A VPC domain with fine-grained access control and the three encryption settings that cannot be added afterwards. Building a public endpoint takes an explicit opt-in, because a public domain with a permissive policy is how this service leaks databases.
aws-rds
Single-instance or Multi-AZ RDS with subnet/parameter/option groups, backups, and monitoring wired correctly.