Terraform module to create documentdb resource on AWS.
We eat, drink, sleep and most importantly love DevOps. We are working towards strategies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy Bigger problems are always solved by breaking them into smaller manageable problems. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller connected yet manageable pieces within the infrastructure.
This module is basically combination of Terraform open source and includes automatation tests and examples. It also helps to create and improve your infrastructure with minimalistic code instead of maintaining the whole infrastructure code yourself.
We have fifty plus terraform modules. A few of them are comepleted and are available for open source usage while a few others are in progress.
This module has a few dependencies:
- Terraform 1.x.x
- Go
- github.com/stretchr/testify/assert
- github.com/gruntwork-io/terratest/modules/terraform
IMPORTANT: Since the master
branch used in source
varies based on new modifications, we suggest that you use the release versions here.
Here is an example of how you can use this module in your inventory structure:
module "documentdb" {
source = "clouddrove/terraform-aws-documentdb/aws"
vpc_id = module.vpc.vpc_id
subnet_list = data.aws_subnet_ids.all.ids
database_name = "rds"
environment = "test"
label_order = ["environment", "name"]
master_password = "test123456"
instance_class = "db.t3.medium"
cluster_size = 1
}
module "documentdb" {
source = "clouddrove/terraform-aws-documentdb/aws"
vpc_id = module.vpc.vpc_id
subnet_list = module.subnets.private_subnet_id
database_name = "rds"
environment = "test"
label_order = ["environment", "name"]
skip_final_snapshot = false
storage_encrypted = true
kms_key_id = module.kms_key.key_arn
tls_enabled = true
instance_class = "db.t3.medium"
cluster_size = 1
}
Name | Description | Type | Default | Required |
---|---|---|---|---|
apply_immediately | Specifies whether any cluster modifications are applied immediately, or during the next maintenance window. | string |
"true" |
no |
attributes | Additional attributes (e.g. 1 ). |
list(any) |
[] |
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 |
"docdb4.0" |
no |
cluster_size | Number of DB instances to create in the cluster | string |
"2" |
no |
database_name | Name of the database. | string |
n/a | yes |
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 |
"" |
no |
environment | Environment (e.g. prod , dev , staging ). |
string |
"" |
no |
instance_class | The instance class to use. For more details, see https://docs.aws.amazon.com/documentdb/latest/developerguide/db-instance-classes.html#db-instance-class-specs . | string |
"db.t3.medium" |
no |
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 |
label_order | Label order, e.g. name ,application . |
list(any) |
[] |
no |
managedby | ManagedBy, eg 'CloudDrove' | string |
"hello@clouddrove.com" |
no |
master_password | (Required unless a snapshot_identifier is provided) Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file. | string |
"" |
no |
master_username | (Required unless a snapshot_identifier is provided) Username for the master DB user. | string |
"root" |
no |
name | Name (e.g. app or cluster ). |
string |
"" |
no |
port | Open port in sg for db communication. | number |
27017 |
no |
preferred_backup_window | Daily time range during which the backups happen. | string |
"07:00-09:00" |
no |
repository | Terraform current module repo | string |
"https://github.com/clouddrove/terraform-aws-documentdb" |
no |
retention_period | Number of days to retain backups for. | string |
"7" |
no |
skip_final_snapshot | Determines whether a final DB snapshot is created before the DB cluster is deleted. | string |
"false" |
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 |
storage_encrypted | Specifies whether the DB cluster is encrypted. | string |
"false" |
no |
subnet_list | List of subnet IDs database instances should deploy into. | list(string) |
n/a | yes |
tls_enabled | When true than cluster using TLS for communication. | bool |
false |
no |
vpc_id | ID of the VPC to deploy database into. | string |
n/a | yes |
Name | Description |
---|---|
arn | Amazon Resource Name (ARN) of the cluster. |
cluster_name | Cluster Identifier. |
master_password | password for the master DB user. |
master_username | Username for the master DB user. |
reader_endpoint | A read-only endpoint of the DocumentDB cluster, automatically load-balanced across replicas. |
writer_endpoint | Endpoint of the DocumentDB cluster. |
In this module testing is performed with terratest and it creates a small piece of infrastructure, matches the output like ARN, ID and Tags name etc and destroy infrastructure in your AWS account. This testing is written in GO, so you need a GO environment in your system.
You need to run the following command in the testing folder:
go test -run Test
If you come accross a bug or have any feedback, please log it in our issue tracker, or feel free to drop us an email at hello@clouddrove.com.
If you have found it worth your time, go ahead and give us a ★ on our GitHub!
At CloudDrove, we offer expert guidance, implementation support and services to help organisations accelerate their journey to the cloud. Our services include docker and container orchestration, cloud migration and adoption, infrastructure automation, application modernisation and remediation, and performance engineering.
We are The Cloud Experts!
We ❤️ Open Source and you can check out our other modules to get help with your new Cloud ideas.