The following content needed to be created and managed:
- Introduction
- Explaination of module
- Intended users
- Resource created and managed by this module
- Example Usages
This repository allows creating MongoDB ReplicaSet in AWS EC2 instances. It includes the following resources:
- Jumpbox Instance (*Optional - If terraform is invoked from Local):
- To access our MongoDB servers
- To copy replication and cluster configutration files to MongoDB servers
- Primary MongoDB Instance
- Secondary MongoDB Instances (you can define the count of read replicas here. By default, this creates 2 secondary nodes)
- AWS CLI must be installed and aws-profile must be already created
- AWS VPC must be already configured with min. 2 private subnets, 2
public subnets, and Nat gateway
- Public Subnets: Jumpbox is setup here
- Private Subnets: MongoDB nodes and NAT gateway
module mongodb {
source = "git::https://github.com/tothenew/terraform-aws-mongodb.git"
region = "<default region>"
secondary_node_type = "<secondary node type>"
primary_node_type = "<primary node type>"
vpc_id = "<vpc id>"
mongo_subnet_ids = "<private subnet ids>"
jumpbox_subnet_ids = "<public subnet ids>"
mongo_database = "<sample database name>"
}
However, below properties can also be passed as custom parameters, otherwise will be picked from variables.tf as default
profile
instance_user
key_name
environment
replica_set_name
mongo_username
num_secondary_nodes
domain_name
ssm_parameter_prefix
Name | Version |
---|---|
terraform | >= 1.3.0 |
aws | >= 3.72 |
Name | Version |
---|---|
aws | >= 3.72 |
Name | Type |
---|---|
random_string | resource |
aws_key_pair | resource |
aws_ssm_parameter | resource |
aws_instance | resource |
aws_security_group | resource |
aws_iam_role | resource |
aws_iam_instance_profile | resource |
aws_iam_role_policy | resource |
Name | Description | Type | Default | Required |
---|---|---|---|---|
secondary_node_type | Instance type of Slave MongoDB Nodes | string |
t2.micro |
yes |
primary_node_type | Instance type of Master MongoDB Node | string |
t2.micro |
yes |
jumpbox_instance_type | Instance type of Bastion Server | string |
t2.nano |
yes |
instance_user | SSH Username | string |
ubuntu |
yes |
key_name | pem key file to ssh into servers | string |
mongo |
yes |
vpc_id | VPC ID where you want to launch your servers | string |
NA |
yes |
environment | Environment Tag Name | string |
DEV |
yes |
mongo_subnet_ids | List of Subnet Ids where MongoDB will be running (should be private) | list |
NA |
yes |
jumpbox_subnet_ids | Subnet IDs where Bastion Server will be running (should be public) | list |
NA |
yes |
vpc_cidr_block | This is for Security Group egress rules | string |
0.0.0.0/0 |
yes |
replica_set_name | Name of the MongoDB Replicaset which will be created | string |
MongoRs |
yes |
mongo_username | MongoDB Username | string |
admin |
yes |
mongo_database | MongoDB Database | string |
admin |
yes |
num_secondary_nodes | Number of Slave MongoDB Nodes | integer |
2 |
yes |
custom_domain | If "true", then the custom domain name will be used for MongoDB else default Private IPs will be used | bool |
flase |
yes |
domain_name | The custom domain name if required | string |
n/a |
yes (only if "custom_domain" is set to true) |
ssm_parameter_prefix | Prefix for SSM Parameter Key Name | string |
MongoDB |
yes |
Module managed by TO THE NEW Pvt. Ltd.
Apache 2 Licensed. See LICENSE for full details.