The purpose of the module is to simplify the process of provisioning MongoDB on AWS cloud using Terraform. Here, we have listed our three different approaches to achieve that. Each approach has it's pros and cons. Choose the right pick for your requirement.
This approach creates EC2 instance(s) and provision MongoDB using Ansible in the specified VPC and subnet. The mongodb data will be persisted in specified EBS volume. You can provision MongoDB server either in a public subnet or in a private subnet using Bastion host.
- Simplified MongoDB provisioner supporting Replication
- EC2 instances can be provisioned with newer MongoDB versions and attach to existing EBS data volumes if versions are compatible.
- MongoDB can be provisioned in either public subnet or in private subnet using Bastion host.
- Dynamic increase/decrease of number of replica nodes is not yet supported.
- No out-of-the-box monitoring support.
Find out more about this approach here
This approach creates an ECS task for mongo and runs/manages that task on EC2 instance of provided instance type. This mongo task
uses a docker plugin called rexray/ebs
to provision and use EBS volume for persistent storage of mongo container.
- Simplified mongo infra management with just Terraform
- Mongo task gets restarted automatically in case of failure
- Easy version upgrades with minimal downtime
- Auto provision of EBS volume
- Built-in ECS monitoring provided in ECS dashboard
- Data volume will not be lost unless deleted manually.
- Rolling deployments are not supported yet due to mongo single instance limitation.
- EBS volume size should be chosen carefully because it is not possible to expand it later as it is managed by docker plugin
Find out more about this approach here
This approcah creates pre configured mongo AMIs using packer tool. Then it provisions the mongodb instances from pre configured AMIs in private subnet.
- It creates immutable infrastructure.
- Easy version upgrades.
- Minimal configuration needed for moving to other cloud providers.
- Maintaining the pre configured AMIs.
Find out more about this approach here