/mongodb-terraform-deployment

An automated setup to deploy a MongoDB Cluster with a Replica Set (1 Primary, n Secondary nodes)

Primary LanguageHCLMIT LicenseMIT

mongodb-terraform-deployment

An automated setup to deploy a MongoDB Cluster with a Replica Set (1 Primary, n Secondary nodes)

This project creates in AWS a VPC, Public/Private subnets, a Jumpbox server in the public subnet, and a MongoDB cluster in the private subnets

Deployment Architecture

Deployment Architecture

Steps to Deploy

  1. Clone this repository
  2. cd into the repository
  3. Edit the variables in the terraform.tfvars file
  vpc_name = "mongo_vpc"
  replica_set_name = "mongoRs"
  num_secondary_nodes = 2
  mongo_username = "admin"
  mongo_password = "mongo4pass"
  mongo_database = "admin"
  1. Set up the AWS CLI on your development machine and configure the ~/.aws/credentials file
  [default]
  aws_access_key_id = xxxxxxxxxxxxxxxxxx
  aws_secret_access_key = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  1. Install Terraform on your development machine
  1. Use "terraform init" to initialize the modules

  2. Use "terraform plan" to view the resources that would be created

  3. Use "terraform apply" to deploy the cluster