Skip to content

DocumentDB

This module creates an Amazon DocumentDB cluster with the specified configuration. It allows you to set parameters such as the number of instances, instance class, engine version, and more.

Usage example

module "document_db" {
  source = "s3::https://apro-terraform-modules.s3.eu-west-1.amazonaws.com/SET_VERSION/document_db.zip"

  name_prefix = "uat-core"
  vpc_id      = var.vpc_id
  subnet_ids  = var.database_subnets
}

Serverless Configuration

module "document_db_serverless" {
  source = "s3::https://apro-terraform-modules.s3.eu-west-1.amazonaws.com/SET_VERSION/document_db.zip"

  name_prefix   = "uat-core"
  vpc_id        = var.vpc_id
  subnet_ids    = var.database_subnets
  use_serverless = true

  serverless_scaling_configuration = {
    min_capacity = 0.5
    max_capacity = 5
  }
}

Inputs

Name Description Type Default Required
allowed_security_groups List of Security Groups to be allowed to access the DocumentDB cluster list(string) [] no
cluster_parameters List of DB parameters to apply
list(object({
apply_method = string
name = string
value = string
}))
[] no
cluster_size Number of instances in the DocumentDB cluster number 1 no
create Create the DocumentDB cluster and associated resources bool true no
db_port Port for the DocumentDB cluster number 27017 no
enable_performance_insights Enable performance insights for the DocumentDB cluster bool false no
engine_version Engine version for the DocumentDB cluster string "5.0.0" no
instance_class Instance class for the DocumentDB cluster string "db.t3.medium" no
master_username Master username for the DocumentDB cluster string "root" no
name_prefix Prefix for the resources string n/a yes
serverless_scaling_configuration Serverless scaling configuration for the DocumentDB cluster
object({
min_capacity = number
max_capacity = number
})
{
"max_capacity": 5,
"min_capacity": 0.5
}
no
storage_type Storage type for the DocumentDB cluster string "standard" no
subnet_ids List of subnet IDs where the DocumentDB cluster will be created list(string) n/a yes
use_serverless Use serverless for the DocumentDB cluster bool false no
vpc_id VPC ID where the DocumentDB cluster will be created string n/a yes

Outputs

Name Description
cluster_endpoint The cluster endpoint
cluster_id The ID of the DocumentDB cluster
cluster_instances List of cluster instances
cluster_resource_id The Resource ID of the DocumentDB cluster
master_user_secret_arn The ARN of the master user secret in AWS Secrets Manager
master_username The master username for the DocumentDB cluster
port The port on which the DocumentDB cluster accepts connections
reader_endpoint The cluster reader endpoint
security_group_id The security group ID of the DocumentDB cluster