Community MongoDB Cluster module developed on top of Bitnami MongoDB docker image. Each node has dedicated AutoScaling group and EBS volume, so node-related changes will affect specific node only, not entire cluster.
- Autoscaling group and EBS volume per node
- EC2 instance self-healing
- Mechanism for reattaching EBS volume after EC2 termination
- [WIP] Route53 auto update
module "mongodb_cluster" {
source = "github.com/htec-infra/terraform-mongodb-community"
namespace = "ProjectName"
environment = "Development"
env_code = "dev"
name = "mongodb-cluster"
instance_type = "t3.medium"
mongodb_version = "4.4.5"
mongodb_storage_size = 100
mongodb_container_cpu = 2048
mongodb_container_memory = 3600
mongodb_nodes = [{
type: "primary",
unique_name: "mondgodb-master",
subnet_id: "subnet-12345abcd"
}, {
type: "secondary",
unique_name: "mondgodb-replica",
subnet_id: "subnet-67890efgh"
}]
}
Name | Version |
---|---|
terraform | >= 0.13 |
aws | ~> 3.0 |
Name | Version |
---|---|
aws | ~> 3.0 |
random | n/a |
Name | Source | Version |
---|---|---|
mongodb_nodes | ./modules/mongodb-node |
Name | Type |
---|---|
aws_ecs_cluster.mongodb | resource |
aws_iam_instance_profile.ecs_instance_profile | resource |
aws_iam_role.ecs_instance_role | resource |
aws_iam_role.ecs_tasks_execution_role | resource |
aws_iam_role_policy.ecs_tasks_inline_role | resource |
aws_iam_role_policy.mongodb_node | resource |
aws_iam_role_policy_attachment.ecs_instance_role_policy_attach | resource |
aws_iam_role_policy_attachment.ecs_instance_ssm_policy | resource |
aws_iam_role_policy_attachment.ecs_tasks_execution_role | resource |
aws_security_group.mongodb | resource |
aws_ssm_parameter.mongo_dba_password | resource |
random_password.mongo_dba | resource |
aws_iam_policy_document.ecs_instance_role | data source |
aws_iam_policy_document.mongodb_ecs_task_inline | data source |
aws_iam_policy_document.mongodb_node | data source |
aws_iam_policy_document.mongodb_tasks_execution_role | data source |
aws_subnet.this | data source |
Name | Description | Type | Default | Required |
---|---|---|---|---|
disable_mongodb_service | Whether to run MongoDB service or not | bool |
false |
no |
env_code | Short environment name tag (e.g. dev, stg, prod) | string |
n/a | yes |
environment | Environment indicator where the MongoDB will be instantiated. E.g. Development, Staging, QA, Production | string |
n/a | yes |
instance_type | Type of ECS container instance type | string |
n/a | yes |
mongodb_container_cpu | CPU capacity required for mongo container ( 1024 == 1 cpu) | number |
1024 |
no |
mongodb_container_memory | Memory required for mongo container | number |
1606 |
no |
mongodb_node_ingress_cidr_block | Allow ingress traffic to the MongoDB node from specified IP CIDRs | list(string) |
[] |
no |
mongodb_node_ingress_sgs | Security group id for container EC2 instance | list(object({ |
[] |
no |
mongodb_nodes | n/a | list(object({ |
n/a | yes |
mongodb_storage_size | Size (GB) of the dedicated EBS for mongodb data | number |
50 |
no |
mongodb_version | Docker image version of mongo | string |
n/a | yes |
name | Base name for the cluster and other resources | string |
n/a | yes |
namespace | Project namespace | string |
n/a | yes |
private_root_domain | Service Discovery Domain name | string |
"" |
no |
resource_name_with_env_suffix | n/a | bool |
false |
no |
service_discovery_namespace_id | The ID of the namespace to use for DNS configuration. | string |
null |
no |
tags | Default tags to be attached for every resource in the module | map(string) |
{} |
no |
No outputs.
- Configure pre-commit hooks
pre-commit install
- Tests are available in
test
directory - In the test directory, run the below command
go test