Skip to content

MongoDb Replica

overview

This stack creates a MongoDb replica:

  • create “n” number of replicas into an existing VPC
  • create one data volume per VM
  • create mongodb keys: ssh, pems, and keyfile
  • place mongodb cluster in private subnet
  • configure mongodb replica through a bastion host
  • limit access through existing database security group
  • use spot instances (optional)

Prerequisites

Completed getting started guide for creating VPC .

Add Project to Config0

  • Go to Home -> click Add Project
  • Select and Click launch-config0 as the launch repository
  • Type branch name >> mongodb
  • Add project name >> mongodb-101
  • Click Add Project

Customized config0.yml

You can create your own config0.yml. (optional)

Sample starter below:

global:
   arguments:
     aws_default_region: eu-west-1
     cloud_tags_hash:
       environment: dev
       purpose: eval-config0
       database: mongodb
       product: ec2
       database_type: nosql
   metadata:
     labels:
        general:
          environment: dev
          purpose: eval-config0
        infrastructure:
          cloud: aws
          product: mongodb
     matchSelectors:
        network_vars:
          labels:
            environment: dev
            purpose: eval-config0
            area: network
            region: eu-west-1
            cloud: aws
infrastructure:
   mongodb_replica:
     stack_name: config0-publish:::mongodb_replica_on_ec2
     arguments:
        vpc_name: selector:::network_vars::vpc_name
        vpc_id: selector:::network_vars::vpc_id
        subnet_ids: selector:::network_vars::private_subnet_ids
        sg_id: selector:::network_vars::db_sg_id
        bastion_sg_id: selector:::network_vars::bastion_sg_id
        bastion_subnet_ids: selector:::network_vars::private_subnet_ids
        mongodb_cluster: mongodb-cluster-dev
        ami_filter: Name=name,Values=ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-*
        ami_owner: 099720109477
        bastion_ami_filter: Name=name,Values=ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*
        bastion_ami_owner: 099720109477
        bastion_destroy: true
        instance_type: t3.micro
        spot: true
        num_of_replicas: 3
        disksize: 25
        volume_size: 25
        volume_mount: /var/lib/mongodb
        volume_fstype: xfs
        mongodb_username: admin123
        mongodb_password: admin123
        publish_to_saas: true
     spec:
       serialization:
         to_base64:
           arguments:
             - cloud_tags_hash
     metadata:
       matchSelectors:
         - network_vars