Answers: <p>It's possible. I would use Terraform for creating the infrastructure on AWS and Ansible for provisioning. You will have to write .tf files and ansible-playbooks in order to do this. </p>
  
  <p>Just to let you know, if all 3 nodes are equal you should do the installation and provisioning once and then create an AMI to set up the rest. Maybe an <a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/AutoScalingGroup.html" rel="nofollow noreferrer">autoscaling</a> group is a possibility too. </p>
  
  <p>Keep in mind that AWS provides <a href="https://aws.amazon.com/es/documentdb/" rel="nofollow noreferrer">documentdb</a> as document-oriented database as a service. It's not mongoDB but it's pretty similar (there are some functions mongo provides and docdb doesn't). </p>
  
Answers: CC BY-SA 4.0
Answers: 2020-04-02T18:21:00.343Z
Answers: 2020-04-02T18:21:00.343Z
Answers: Bruno Gonzalez
Body: <p>I am trying to create a 3 node MongoDB replica set using automation (ansible or terraform) in AWS. I am able to do this in the management console of AWS, but I'm not sure how to approach it.</p>
  
  <p>Essentially, the script must create the instances and then set up a 3 node MongoDB replica set on them. I want to add an EBS disk on it and then maybe secure it.</p>
  
  <p>All of this via Ansible (or Terrafor) so I can automate it fully.</p>
  
  <p>Is this possible?</p>
  
  <p>Thanks!!</p>
  
Comments: CC BY-SA 4.0
Comments: 2020-04-02T10:17:29.080Z
Comments: hi Prim3. This sounds eminently doable with both Ansible and Terraform. The answer to your question is undoubtedly simply "yes". Perhaps you could narrow down the question a bit - what _aspects_ of this task seem difficult, complicated or uncertain to you?
Comments: Bruce Becker
Comments: CC BY-SA 4.0
Comments: 2021-04-17T12:55:02.547Z
Comments: @BruceBecker I want to do the same but I couldn't find simple and clear tutorial/article to do this. Can you please guide me to right direction.
Comments: Muhammad Tariq
Tags: <ansible><terraform>
Title: Creating ec2 instances and installing mongoDB using automation
UserDisplayName: prim3
ThreadText: # Creating ec2 instances and installing mongoDB using automation
  
  (Asked by: username_0 on 2020-04-02)
  
  I am trying to create a 3 node MongoDB replica set using automation (ansible or terraform) in AWS. I am able to do this in the management console of AWS, but I'm not sure how to approach it.
  
  Essentially, the script must create the instances and then set up a 3 node MongoDB replica set on them. I want to add an EBS disk on it and then maybe secure it.
  
  All of this via Ansible (or Terrafor) so I can automate it fully.
  
  Is this possible?
  
  Thanks!!
  
  **Tags:** ansible, terraform
  
  > **Comments:**
  > **username_1**: hi username_0. This sounds eminently doable with both Ansible and Terraform. The answer to your question is undoubtedly simply "yes". Perhaps you could narrow down the question a bit - what _aspects_ of this task seem difficult, complicated or uncertain to you?  
  > **username_2**: @username_1 I want to do the same but I couldn't find simple and clear tutorial/article to do this. Can you please guide me to right direction.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2020-04-02. Score: 1
  
  It's possible. I would use Terraform for creating the infrastructure on AWS and Ansible for provisioning. You will have to write .tf files and ansible-playbooks in order to do this.
  
  Just to let you know, if all 3 nodes are equal you should do the installation and provisioning once and then create an AMI to set up the rest. Maybe an [autoscaling](https://docs.aws.amazon.com/autoscaling/ec2/userguide/AutoScalingGroup.html) group is a possibility too.
  
  Keep in mind that AWS provides [documentdb](https://aws.amazon.com/es/documentdb/) as document-oriented database as a service. It's not mongoDB but it's pretty similar (there are some functions mongo provides and docdb doesn't).
  
  
  ---
  
  