Skip to content

Module Structure

terraform-aws-arc-document-db

Latest Release Last Updated Terraform GitHub Actions

Quality gate

snyk

Overview

The SourceFuse AWS Reference Architecture (ARC) Terraform module for managing AWS DocumentDB offers a streamlined solution for provisioning, configuring, and managing DocumentDB clusters within the Amazon Web Services (AWS) environment. This Terraform module is specifically designed to simplify the deployment and maintenance of DocumentDB.

For more information about this repository and its usage, please see Terraform AWS ARC Document DB Usage Guide.

Usage

To see a full example, check out the main.tf file in the example folder.

module "example_doc_db_cluster" {
  source  = "sourcefuse/arc-document-db/aws"  
  // we recommend to pin the version we aren't simply for an example reference against our latest changes.
  namespace   = var.namespace
  environment = var.environment

  doc_db_cluster_name = var.doc_db_cluster_name
  cluster_size        = var.cluster_size
  master_username     = var.master_username
  instance_class      = var.instance_class
  vpc_id              = data.aws_vpc.vpc_id.id
  subnet_ids          = data.aws_subnets.private.ids

  tags = module.tags.tags

}

Requirements

Name Version
terraform ~> 1.3, < 2.0.0
aws >= 4.0, < 6.0

Providers

Name Version
aws 4.67.0

Modules

Name Source Version
doc_db_cluster cloudposse/documentdb-cluster/aws 0.24.0

Resources

Name Type
aws_ssm_parameter.documentdb_host resource
aws_ssm_parameter.documentdb_port resource
aws_ssm_parameter.documentdb_username resource

Inputs

Name Description Type Default Required
allowed_cidr_blocks List of CIDR blocks to be allowed to connect to the DocumentDB cluster list(string) [] no
allowed_security_groups List of existing Security Groups to be allowed to connect to the DocumentDB cluster list(string) [] no
apply_immediately Specifies whether any cluster modifications are applied immediately, or during the next maintenance window bool true no
auto_minor_version_upgrade Specifies whether any minor engine upgrades will be applied automatically to the DB instance during the maintenance window or not bool true no
cluster_dns_name Name of the cluster CNAME record to create in the parent DNS zone specified by zone_id. If left empty, the name will be auto-asigned using the format master.var.name string "" no
cluster_family The family of the DocumentDB cluster parameter group. For more details, see https://docs.aws.amazon.com/documentdb/latest/developerguide/db-cluster-parameter-group-create.html string "docdb3.6" no
cluster_parameters List of DB parameters to apply
list(object({
apply_method = string
name = string
value = string
}))
[] no
cluster_size Number of DB instances to create in the cluster number n/a yes
db_port The port on which the DB accepts connections number 27017 no
doc_db_cluster_name Name of the DB cluster string n/a yes
documentdb_host The name for the DocumentDB host SSM parameter string "/arc/doc_db/host" no
documentdb_port The name for the DocumentDB port SSM parameter string "/arc/doc_db/port" no
documentdb_username The name for the DocumentDB username SSM parameter string "/arc/doc_db/username" no
enabled_cloudwatch_logs_exports List of log types to export to cloudwatch. The following log types are supported: audit, error, general, slowquery list(string) [] no
engine The name of the database engine to be used for this DB cluster. Defaults to docdb. Valid values: docdb string "docdb" no
engine_version The version number of the database engine to use string "3.6.0" no
environment environment value, e.g 'prod', 'staging', 'dev', 'UAT' string "" no
instance_class Instance class to use for the DB instances in the cluster string n/a yes
kms_key_id The ARN for the KMS encryption key. When specifying kms_key_id, storage_encrypted needs to be set to true string "" no
master_username Username for the master DB user string n/a yes
namespace Namespace for the resources. string n/a yes
preferred_backup_window Daily time range during which the backups happen string "07:00-09:00" no
preferred_maintenance_window The window to perform maintenance in. Syntax: ddd:hh24:mi-ddd:hh24:mi. string "Mon:22:00-Mon:23:00" no
reader_dns_name Name of the reader endpoint CNAME record to create in the parent DNS zone specified by zone_id. If left empty, the name will be auto-asigned using the format replicas.var.name string "" no
retention_period Number of days to retain backups for number 5 no
skip_final_snapshot Determines whether a final DB snapshot is created before the DB cluster is deleted bool true no
snapshot_identifier Specifies whether or not to create this cluster from a snapshot. You can use either the name or ARN when specifying a DB cluster snapshot, or the ARN when specifying a DB snapshot string "" no
ssm_parameter_enabled Whether to create an SSM parameter for the master password bool true no
ssm_parameter_path_prefix The path prefix for the created SSM parameter e.g. '/docdb/master-password/dev'. ssm_parameter_enabled must be set to true for this to take affect. string "/arc/doc_db/master_password/" no
storage_encrypted Specifies whether the DB cluster is encrypted bool true no
subnet_ids List of subnet IDs to create the DB cluster in list(string) n/a yes
tags Additional tags to apply to all resources map(string) {} no
vpc_id ID of the VPC to create the DB cluster in string n/a yes
zone_id Route53 parent zone ID. If provided (not empty), the module will create sub-domain DNS records for the DocumentDB master and replicas string "" no

Outputs

Name Description
arn Amazon Resource Name (ARN) of the DocumentDB cluster
cluster_name DocumentDB Cluster Identifier
endpoint Endpoint of the DocumentDB cluster
reader_endpoint Read-only endpoint of the DocumentDB cluster, automatically load-balanced across replicas

Git commits

while Contributing or doing git commit please specify the breaking change in your commit message whether its major,minor or patch

For Example

git commit -m "your commit message #major"
By specifying this , it will bump the version and if you dont specify this in your commit message then by default it will consider patch and will bump that accordingly

Development

Prerequisites

Configurations

  • Configure pre-commit hooks
    pre-commit install
    

Tests

  • Tests are available in test directory
  • Configure the dependencies
    1
    2
    3
    cd test/
    go mod init github.com/sourcefuse/terraform-aws-refarch-<module_name>
    go get github.com/gruntwork-io/terratest/modules/terraform
    
  • Now execute the test
    go test -timeout  30m
    

Authors

This project is authored by: - SourceFuse ARC Team