Giter VIP home page Giter VIP logo

cloudformation-mongodb's Introduction

Deploying MongoDB Replicaset Architecture in AWS Private VPC

This reference architecture provides a set of YAML templates for deploying the following AWS services :

  • Amazon IAM
  • Amazon Security Group
  • Amazon EC2
  • Amazon Route53

Prerequisites Notes

The Cloudformation Security Group IP address is open by default (testing purpose). You should update the Security Group Access with your own IP Address to ensure your instances security.

Before you can deploy this process, you need the following:

  • Your AWS account must have one VPC available to be created in the selected region
  • Amazon EC2 key pair
  • Installed Domain in Route 53.
  • cloudformation-vpc (Assuming you already have installed VPC https://github.com/thinegan/cloudformation-vpc )

We have test launch this CloudFormation stack in the following Region in our account:

  • US East (N. Virginia)

infrastructure-overview

The repository consists of a set of nested templates that deploy the following:

MongoDB Cloud Manager Setup

Create a New Project, click "New Project" CloudManager-Setup1

Select "Cloud Manager" and Click "Next" CloudManager-Setup2

Enter Name of your project and click "Next" CloudManager-Setup3

You project will be created. CloudManager-Setup4

Goto Project "Deployment". Under "Crytera > Timeclonedbrep", select "Agents" and "Downloads & Settings". Since, I'm using Debian Os, select Automation "Ubuntu (15.x, 16.x) - DEB" CloudManager-Setup5

Use mmsGroupId and mmsApiKey to setup mms agent in your cloudformation script. CloudManager-Setup6

A completed deployed mms automation agent running after completed cloudformation run. CloudManager-Setup7

Goto Deployment > Security > Edit Setting. Select "Authentication Mechanisms [X] Username/Password CloudManager-Setup8

Continue "Next" without enabling SSL. We will enable it on the process. CloudManager-Setup9

Save and Initiate first Credential will be blank password. Remember, you need re-run this credential process again to generate new password. CloudManager-Setup10

Deploy you changes. CloudManager-Setup11

Re-run the entire credential process again, only this time Agent mms-automation user will generate a password. Don't Save and Deploy yet. CloudManager-Setup12

Login to your Mongo Replica Master and create admin user first, based on the credential you got from Cloud Manager. CloudManager-Setup13

Now, Save, Review and Deploy your changes, CloudManager-Setup14

Next, Goto Deployment > Server.
Install Monitoring Agent in Master Replica
Install Monitoring and Backup Agent in Secondary Replica CloudManager-Setup15

Confirm, Review and Deploy. CloudManager-Setup16

Goto Deployment > Processes Click "Manage Existing" CloudManager-Setup17

Add Master hostname and mongo port. Turn on "Enable Authentication". CloudManager-Setup18

Choose, Auth Mechanism "Username/Password". Enter Username and Password. Select "Continue". CloudManager-Setup19

Continue but make sure you see all the processes in your deployment. CloudManager-Setup20

Check, "I understand that this require..." and click "Continue". CloudManager-Setup21

Check, "Yes, import users and roles from this deployment item".
Click "Continue". CloudManager-Setup22

Proceed after "Automation Agent Successfully Verified". CloudManager-Setup23

Proceed after "Initialing Automation for your Deployment". CloudManager-Setup24

Save, Review and Deploy. CloudManager-Setup25

Replicaset Processes Display Completed! CloudManager-Setup26

Goto Deployment > Security > MongoDB User.
Turn on "Enforce Consistent Set".
Confirm "Enforce Consistent Set". CloudManager-Setup27

Save, Review and Deploy. CloudManager-Setup28

Now, Lets start the step to enable TLS/SSL setting.
Please ensure you already have certs/pem install in your servers.
Goto Deployment > Security > Authentication & TLS/SSL.
Edit Setting and proceed to "Authentication Mechanisms" and Click "Next". CloudManager-Setup29

Enable TLS/SSL option.
Enter TLS/SSL CA File Path.
Switch "Client Certificate Mode" to "Require". CloudManager-Setup30

Enter PEM file for Automation, Backup and Monitoring Agent.
Next Click "Save". CloudManager-Setup31

Save, Review and Deploy. CloudManager-Setup32

Proceed, Review and Deploy. CloudManager-Setup33

Changes will shows as Enabled in TLS/SSL. CloudManager-Setup34

Next, to Ensure the TLS/SSL support enabled in the Mongo replicaset,
Goto Deployment > Processes. Select Replicaset Name and choose "Modify" setting.
Update the Following:
DB Directory Path Prefix = /data
bindIp = 0.0.0.0
sslMode = requireSSL
sslPEMKeyFile = /etc/ssl/certs/mongodb.pem
Then, click "Apply". CloudManager-Setup35

Now continue the previous step for the rest of the servers. Mostly the update is just the following :
sslMode = requireSSL
sslPEMKeyFile = /etc/ssl/certs/mongodb.pem
You will see the icon changes in your replicaset during this process. CloudManager-Setup36

Save, Review, Confirm and Deploy. CloudManager-Setup37

Proceed to Confirm and Deploy CloudManager-Setup38

Once Deploy is completed, you can double check the SSL/TLS changes by select a host and click the connect option to see example of connection command. CloudManager-Setup39

Click "Metric" to monitor all MongoDB Traffic/Usage. CloudManager-Setup40

Refer to "Data Explorer" for overall Data list. CloudManager-Setup41

Adding a New User. Click "Add New User". CloudManager-Setup42

Add the following.
Identitier: test (dbname)
username: user1
Roles: dbOwner
Password: xxxxxx
Click "Add User". CloudManager-Setup43

Save, Review and Deploy. CloudManager-Setup44

Once changes take effects. You can double check your changes in your cli. CloudManager-Setup45

Troubleshoot Slow Query by Checking "Real Time" and check slowest operation. CloudManager-Setup46

Also you can set log rotate from by your preference. CloudManager-Setup47

Finaly, you can remove the replicaset if you don't like and rebuild all over again. CloudManager-Setup48

Infrastructure-as-Code

A template can be used repeatedly to create identical copies of the same stack (or to use as a foundation to start a new stack). Templates are simple YAML- or JSON-formatted text files that can be placed under your normal source control mechanisms, stored in private or public locations such as Amazon S3, and exchanged via email. With CloudFormation, you can see exactly which AWS resources make up a stack. You retain full control and have the ability to modify any of the AWS resources created as part of a stack.

Self-documenting

Fed up with outdated documentation on your infrastructure or environments? Still keep manual documentation of IP ranges, security group rules, etc.?

With CloudFormation, your template becomes your documentation. Want to see exactly what you have deployed? Just look at your template. If you keep it in source control, then you can also look back at exactly which changes were made and by whom.

Intelligent updating & rollback

CloudFormation not only handles the initial deployment of your infrastructure and environments, but it can also manage the whole lifecycle, including future updates. During updates, you have fine-grained control and visibility over how changes are applied, using functionality such as change sets, rolling update policies and stack policies.

Add a new item to this list

If you found yourself wishing this set of frequently asked questions had an answer for a particular problem, please submit a pull request. The chances are that others will also benefit from having the answer listed here.

Contributing

Please create a new GitHub issue for any feature requests, bugs, or documentation improvements.

Where possible, please also submit a pull request for the change.

Author

Thinegan Ratnam

Copyright and License

Copyright 2018 Thinegan Ratnam

Code released under the MIT License.

cloudformation-mongodb's People

Contributors

thinegan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.