MongoDB Atlas on the AWS Cloud

Quick Start Reference Deployment

QS

March 2021
Jason Mimick, MongoDB Inc.
Vinod Shukla, AWS Quick Start team

Visit our GitHub repository for source files and to post feedback, report bugs, or submit feature ideas for this Quick Start.

This Quick Start was created by MongoDB Inc. in collaboration with Amazon Web Services (AWS). Quick Starts are automated reference deployments that use AWS CloudFormation templates to deploy key technologies on AWS, following AWS best practices.

Overview

Use this Quick Start to launch a fully managed MongoDB Atlas deployment on the AWS Cloud.

MongoDB Atlas is a global cloud document database service for modern applications. Deploying a fully managed MongoDB helps to ensure availability, scalability, and security compliance. You can extend your data with the MongoDB cloud platform, including full-text search, mobile sync, and automated data tiering.

This Quick Start is for developers and DevOps professionals who want to create flexible, fully managed clusters on MongoDB Atlas. The template creates an Atlas project with a standard, single-region M10 cluster and can be customized for different cluster configurations and project settings.

By default, every MongoDB Atlas cluster includes the following:

  • Support for the latest MongoDB enterprise database versions

  • A three-node (minimally) replica set for high availability, deployed into a new VPC

  • Built-in security defaults, including always-on authentication and end-to-end encryption

  • Fully managed database lifecycle with automated patches, backups, and monitoring

  • Performance optimization features such as automatic scaling, index suggestions, and intelligent data tiering

Amazon may share user-deployment information with the AWS Partner that collaborated with AWS on the Quick Start.

MongoDB Atlas on AWS

Use this Quick Start to automatically set up the following MongoDB Atlas environment on AWS:

  • A MongoDB Atlas cluster consisting of a minimum three-node replica set, distributed across Availability Zones in the AWS Region of your choice, in a new virtual private cloud (VPC).

  • A MongoDB Atlas project with an optional VPC network peering connection to a new or existing VPC on AWS to allow outbound internet connectivity to your Atlas cluster.

  • An AWS Identity and Access Management (IAM) instance role with resource-level permissions for access to AWS services and MongoDB Atlas.

  • A MongoDB database IAM role with read and write access to the MongoDB Atlas cluster in addition to a MongoDB Atlas IP access list entry for the database user to restrict access to authenticated users.

This Quick Start provisions complete MongoDB Atlas through CloudFormation using official MongoDB Atlas AWS CloudFormation resource types.

AWS costs

You are responsible for the cost of the AWS services and any third-party licenses used while running this Quick Start. There is no additional cost for using the Quick Start.

The AWS CloudFormation templates for Quick Starts include configuration parameters that you can customize. Some of the settings, such as the instance type, affect the cost of deployment. For cost estimates, see the pricing pages for each AWS service you use. Prices are subject to change.

After you deploy the Quick Start, create AWS Cost and Usage Reports to deliver billing metrics to an Amazon Simple Storage Service (Amazon S3) bucket in your account. These reports provide cost estimates based on usage throughout each month and aggregate the data at the end of the month. For more information, see What are AWS Cost and Usage Reports?

Software licenses

This Quick Start deploys MongoDB Atlas with the latest stable MongoDB enterprise version, which is licensed and distributed under the Server Side Public License (SSPL).

Architecture

Deploying this Quick Start with peering for a new VPC with default parameters builds the following MongoDB Atlas environment in the AWS Cloud.

Architecture
Figure 1. Quick Start architecture for MongoDB Atlas

As shown in Figure 1, the Quick Start sets up the following:

  • A VPC that spans two Availability Zones. The VPC is configured with public subnets, according to AWS best practices, to provide you with your own virtual network on AWS.*

  • In the public subnets, managed network address translation (NAT) gateways to allow outbound internet access.*

  • A VPC peering connection between your VPC and the MongoDB Atlas VPC.

  • A VPC for the MongoDB Atlas project that spans at least three Availability Zones. This includes a fully managed MongoDB Atlas cluster, a database user, and an IP access list entry.

*The template that deploys the Quick Start into an existing VPC skips the components marked by asterisks and prompts you for your existing VPC configuration.

Deploying Atlas without peering is the simplest deployment option. It skips the VPC resources and creates only MongoDB Atlas resources using MongoDB CloudFormation resource types.

Planning the deployment

Specialized knowledge

This deployment requires a moderate level of familiarity with AWS services. If you’re new to AWS, see Getting Started Resource Center and AWS Training and Certification. These sites provide materials for learning how to design, deploy, and operate your infrastructure and applications on the AWS Cloud.

This Quick Start assumes familiarity with MongoDB Atlas. For more information, see Get Started with Atlas.

This Quick Start uses the official MongoDB Atlas AWS CloudFormation resource types.

AWS account

If you don’t already have an AWS account, create one at https://aws.amazon.com by following the on-screen instructions. Part of the sign-up process involves receiving a phone call and entering a PIN using the phone keypad.

Your AWS account is automatically signed up for all AWS services. You are charged only for the services you use.

Technical requirements

Before you launch the Quick Start, review the following information and ensure that your account is properly configured. Otherwise, deployment might fail.

Resource quotas

If necessary, request service quota increases for the following resources. You might request quota increases to avoid exceeding the default limits for any resources that are shared across multiple deployments. The Service Quotas console displays your usage and quotas for some aspects of some services. For more information, see What is Service Quotas? and AWS service quotas.

Resource This deployment uses

MongoDB::Atlas::Project

1

MongoDB::Atlas::Cluster

1

MongoDB::Atlas::DatabaseUser

1

MongoDB::Atlas::ProjectIPAccessList

1

MongoDB::Atlas::NetworkPeering

1

VPCs

1

IAM roles

1

Secrets

1

Supported Regions

MongoDB Atlas is available across most AWS Regions. For more information, see Amazon Web Services (AWS).

Certain Regions are available on an opt-in basis. For more information, see Managing AWS Regions.

IAM permissions

Before launching the Quick Start, you must sign in to the AWS Management Console with IAM permissions for the resources that the templates deploy. The AdministratorAccess managed policy within IAM provides sufficient permissions, although your organization may choose to use a custom policy with more restrictions. For more information, see AWS managed policies for job functions.

Prepare your AWS account

This Quick Start uses MongoDB Atlas CloudFormation resource types and automatically registers them in the AWS Region of your choice. Once it’s running, you can safely skip this step for additional deployments in each Region by setting the RegisterMongoDBResources parameter to No.

Prepare your MongoDB Inc. account

A MongoDB Atlas programmatic API key must be generated with the appropriate permissions and network access entries so that AWS CloudFormation can successfully authenticate the MongoDB cloud. For more information about creating and managing API keys, see Programmatic Access to Atlas.

Deployment options

This Quick Start provides three deployment options:

  • Deploy MongoDB Atlas without VPC peering. This option peers MongoDB Atlas with your existing VPC.

  • Deploy MongoDB Atlas with VPC peering into a new VPC (end-to-end deployment). This option builds a complete MongoDB Atlas environment within AWS consisting of a project, cluster, and more.

  • Deploy MongoDB Atlas with VPC peering into an existing VPC. This option peers MongoDB Atlas with a new VPC.

For greater security, each option provisions an AWS IAM role and corresponding MongoDB database user. This Quick Start provides separate templates for these options. It also lets you configure database cluster tier settings and other MongoDB Atlas settings, as discussed later in this guide.

Deployment steps

Sign in to your AWS account

  1. Sign in to your AWS account at https://aws.amazon.com with an IAM user role that has the necessary permissions. For details, see Planning the deployment earlier in this guide.

  2. Make sure that your AWS account is configured correctly, as discussed in the Technical requirements section.

Launch the Quick Start

You are responsible for the cost of the AWS services used while running this Quick Start reference deployment. There is no additional cost for using this Quick Start. For full details, see the pricing pages for each AWS service used by this Quick Start. Prices are subject to change.
  1. Sign in to your AWS account, and choose one of the following options to launch the AWS CloudFormation template. For help with choosing an option, see deployment options earlier in this guide.

    Deploy MongoDB Atlas without VPC peering

    View template

    Deploy MongoDB Atlas with VPC peering into a new VPC

    View template

    Deploy MongoDB Atlas with VPC peering into an existing VPC

    View template

    Each deployment takes about 10–20 minutes to complete.

  2. Check the AWS Region that’s displayed in the upper-right corner of the navigation bar, and change it if necessary. This is where the CloudFormation resource types for MongoDB Atlas are built and deployed. The template is launched in the us-east-1 Region by default. Note that resource types must be currently registered within each Region you use.

  3. On the Create stack page, keep the default setting for the template URL, and then choose Next.

  4. On the Specify stack details page, change the stack name if needed. Review the parameters for the template. Provide values for the parameters that require input. For all other parameters, review the default settings, and customize them as necessary.

  5. On the Configure stack options page, you can specify tags (key-value pairs) for resources in your stack and set advanced options. When you’re finished, choose Next.

  6. On the Review page, review and confirm the template settings. Under Capabilities, select the two check boxes to acknowledge that the template creates IAM resources and might require the ability to automatically expand macros.

  7. Choose Create stack to deploy the stack.

  8. Monitor the status of the stack. When the status is CREATE_COMPLETE, the MongoDB Atlas deployment is ready.

  9. Use the values displayed in the Outputs tab for the stack, as shown in Figure 2, to view the created resources.

cfn_outputs
Figure 2. MongoDB Atlas outputs after successful deployment

Test the deployment

There are two ways to test your deployment:

  1. When the deployment completes, locate the new deployment project ID in the stack outputs, which you can use to open the MongoDB Atlas web console at http://cloud.mongodb.com/v2/<ProjectId>.

  2. Use the mongo shell. For more information, see Connect to a MongoDB Atlas Cluster using AWS IAM Credentials.

Best practices for using MongoDB Atlas on AWS

There are many considerations for production-grade deployments. While this Quick Start demonstrates some of these, such as database-user security and peering, see Atlas Production Best Practices for the latest information.

Choosing the correct Atlas cluster tier and configuration is an important step in setting up a successful production MongoDB deployment. You can always modify a cluster at a later time, but getting started with the right configuration is possible with a few calculations based on your data set size and network requirements. For more information, see MongoDB Atlas Production Considerations.

Security

This Quick Start provisions a cluster with security and TLS enabled by default. Optionally, network peering can be enabled on a new or existing AWS VPC. For more information, see MongoDB Security Features and Setup.

If you plan to use AWS Lambda, ensure that you follow the recommendations from Best Practices Connecting from AWS Lambda.

MongoDB Atlas CloudFormation resource reference

  • MongoDB::Atlas::Project — A logical grouping of clusters. You can have multiple clusters within a single project and multiple projects within a single organization.

  • MongoDB::Atlas::Cluster — A set of nodes comprising a MongoDB deployment and database. In Atlas, clusters can be replica sets or sharded deployments.

  • MongoDB::Atlas::DatabaseUser — Credentials used to authenticate a client to access a MongoDB database deployment. You can assign privileges to a database user to determine a user’s access level to a cluster. Database users are different from Atlas users. Database users have access to MongoDB deployments but not the Atlas application.

  • MongoDB::Atlas::ProjectIPAccessList — Atlas allows only client connections to the cluster from entries in the project’s IP access list. Each entry is either a single IP address or CIDR.

  • MongoDB::Atlas::NetworkPeering — Process by which two internet networks connect and exchange traffic. You can directly peer your VPC with the Atlas VPC created for your MongoDB clusters. Using network peering, your application servers can connect directly to Atlas while remaining isolated from public networks.

FAQ

Q. I encountered a CREATE_FAILED error when I launched the Quick Start.

A. If AWS CloudFormation fails to create the stack, we recommend that you relaunch the template with Rollback on failure set to Disabled. (This setting is under Advanced in the AWS CloudFormation console, Options page.) With this setting, the stack’s state is retained, and the instance remains running so you can troubleshoot the issue. (For Windows, look at the log files in %ProgramFiles%\Amazon\EC2ConfigService and C:\cfn\log.)

When you set Rollback on failure to Disabled, you continue to incur AWS charges for the stack. Ensure that you delete the stack when you finish troubleshooting. For more information, see Troubleshooting AWS CloudFormation.

Q. I encountered a size limitation error when I deployed the AWS CloudFormation templates.

A. We recommend that you launch the Quick Start templates from the links in this guide or from another S3 bucket. If you deploy the templates from a local copy on your computer or from a location other than an S3 bucket, you might encounter template size limitations. For more information, see AWS CloudFormation quotas.

Q. Do I need to run the RegisterMongoDBResource step each time?

A. No. You must run this step only once per Region.

Q. What does the RegisterMongoDBResource step do?

A. It registers each of the MongoDB Atlas CloudFormation resource types. This is a standard requirement for CloudFormation. For more information, see Custom resource.

Troubleshooting

Errors can typlically be resolved by inspecting the CloudFormation event logs or CloudWatch logs created by the MongoDB Atlas CloudFormation resources.

If a stack fails to deploy, check the Events tab. If the error occurs for one of the MongoDB Atlas resources (for example, MongoDB::Atlas::Cluster), you will find a corresponding Amazon CloudWatch Logs group called mongodb-atlas-cluster-logs. Locate this group, and check the latest log entry to identify the issue.

Parameter reference

Unless you are customizing the Quick Start templates for your own deployment projects, we recommend that you keep the default settings for the parameters labeled Quick Start S3 bucket name, Quick Start S3 bucket Region, and Quick Start S3 key prefix. Changing these parameter settings automatically updates code references to point to a new Quick Start location. For more information, see the AWS Quick Start Contributor’s Guide.

Parameters for deploying MongoDB Atlas without VPC peering.

Table 1. MongoDB Atlas API key configuration
Parameter label (name) Default value Description

MongoDB Atlas API public key (PublicKey)

PublicKey

MongoDB cloud public API key.

MongoDB Atlas API private key (PrivateKey)

PrivateKey

MongoDB cloud private API key.

MongoDB Atlas API organization ID (OrgId)

OrgId

MongoDB cloud organization ID.

Table 2. MongoDB Atlas configuration
Parameter label (name) Default value Description

Register MongoDB Atlas CloudFormation resources (RegisterMongoDBResources)

Yes

Choose "Yes" to register MongoDB Atlas CloudFormation resource types. If you already registered resources in your AWS Region, enter "No."

Name of new Atlas project (ProjectName)

aws-quickstart

Name of the project.

Name of new cluster (ClusterName)

Cluster-1

Name of the cluster as it appears in Atlas. This name cannot be changed after the cluster is created.

AWS Region for Atlas cluster (ClusterRegion)

us-east-1

AWS Region where the Atlas database cluster runs.

MongoDB Atlas instance size (ClusterInstanceSize)

M10

Atlas provides different cluster tiers, each with a default storage capacity and RAM size. The cluster you choose is used for all data-bearing hosts in your cluster tier (see https://docs.atlas.mongodb.com/reference/amazon-aws/#amazon-aws).

Table 3. AWS Quick Start configuration
Parameter label (name) Default value Description

Quick Start S3 bucket name (QSS3BucketName)

aws-quickstart

S3 bucket name for the Quick Start assets. This string can include numbers, lowercase letters, uppercase letters, and hyphens (-). It cannot start or end with a hyphen (-).

Quick Start S3 key prefix (QSS3KeyPrefix)

quickstart-mongodb-atlas/

S3 key prefix for the Quick Start assets. Quick Start key prefix can include numbers, lowercase letters, uppercase letters, hyphens (-), and forward slashes (/).

Quick Start S3 bucket Region (QSS3BucketRegion)

us-east-1

AWS Region where the Quick Start S3 bucket (QSS3BucketName) is hosted. If you use your own bucket, you must specify this value.

Parameters for deploying MongoDB Atlas with VPC peering into a new VPC.

Table 4. Network configuration
Parameter label (name) Default value Description

Availability Zones (AvailabilityZones)

Requires input

List of Availability Zones to use for the VPC subnets. You can specify two Availability Zones.

VPC CIDR. (VPCCIDR)

10.0.0.0/16

CIDR block for the VPC.

Private subnet 1 CIDR (PrivateSubnet1CIDR)

10.0.0.0/19

CIDR block for the private subnet, located in Availability Zone 1.

Private subnet 2 CIDR (PrivateSubnet2CIDR)

10.0.32.0/19

CIDR block for the private subnet, located in Availability Zone 2.

Public subnet 1 CIDR (PublicSubnet1CIDR)

10.0.128.0/20

CIDR block for public (DMZ) subnet 1, located in Availability Zone 1.

Public subnet 2 CIDR (PublicSubnet2CIDR)

10.0.144.0/20

CIDR block for public (DMZ) subnet 2, located in Availability Zone 2.

VPC peering CIDR block (RouteTableCIDRBlock)

Requires input

CIDR block for VPC peering.

Table 5. MongoDB Atlas API key configuration
Parameter label (name) Default value Description

MongoDB Atlas API public key (PublicKey)

PublicKey

Your MongoDB cloud public API key.

MongoDB Atlas API private key (PrivateKey)

PrivateKey

Your MongoDB cloud private API key.

MongoDB Atlas API organization ID (OrgId)

OrgId

Your MongoDB cloud organization ID.

Table 6. MongoDB Atlas configuration
Parameter label (name) Default value Description

Register MongoDB Atlas CloudFormation resources (RegisterMongoDBResources)

Yes

Enter "Yes" to register MongoDB Atlas CloudFormation resource types. If you already registered resources in your AWS Region, enter "No."

Name of new Atlas project (ProjectName)

aws-quickstart-newvpc

Name of the project.

Name of new cluster (ClusterName)

Cluster-1

Name of the cluster as it appears in Atlas. This name cannot be changed after the cluster is created.

AWS Region for Atlas cluster (ClusterRegion)

us-east-1

AWS Region where the Atlas database runs.

MongoDB Atlas instance size (ClusterInstanceSize)

M10

Atlas provides different cluster tiers, each with a default storage capacity and RAM size. The cluster you choose is used for all data-bearing hosts in your cluster tier (see https://docs.atlas.mongodb.com/reference/amazon-aws/#amazon-aws).

Table 7. AWS Quick Start configuration
Parameter label (name) Default value Description

Quick Start S3 bucket name (QSS3BucketName)

aws-quickstart

S3 bucket name for the Quick Start assets. This string can include numbers, lowercase letters, uppercase letters, and hyphens (-). It cannot start or end with a hyphen (-).

Quick Start S3 key prefix (QSS3KeyPrefix)

quickstart-mongodb-atlas/

S3 key prefix for the Quick Start assets. Quick Start key prefix can include numbers, lowercase letters, uppercase letters, hyphens (-), and forward slashes (/).

Quick Start S3 bucket Region (QSS3BucketRegion)

us-east-1

AWS Region where the Quick Start S3 bucket (QSS3BucketName) is hosted. If you use your own bucket, you must specify this value.

Parameters for deploying MongoDB Atlas with VPC peering into an existing VPC.

Table 8. Network configuration
Parameter label (name) Default value Description

AWS VPC to peer with (VPC)

Requires input

VPC ID of your existing VPC that you want to peer to. This is typically the VPC that your application uses.

VPC peering CIDR block (RouteTableCIDRBlock)

Requires input

CIDR block to use for VPC peering.

Table 9. MongoDB Atlas API key configuration
Parameter label (name) Default value Description

MongoDB Atlas API public key (PublicKey)

PublicKey

MongoDB cloud public API key.

MongoDB Atlas API private key (PrivateKey)

PrivateKey

MongoDB cloud private API key.

MongoDB Atlas API organization ID (OrgId)

OrgId

MongoDB cloud organization ID.

Table 10. MongoDB Atlas configuration
Parameter label (name) Default value Description

Register MongoDB Atlas CloudFormation resources (RegisterMongoDBResources)

Yes

Choose "Yes" to register MongoDB Atlas CloudFormation resource types. If you already registered resources in your AWS Region, enter "No."

Name of new Atlas project (ProjectName)

aws-quickstart-vpc

Name of the project.

Name of new cluster (ClusterName)

Cluster-1

Name of the cluster as it appears in Atlas. This name cannot be changed after the cluster is created.

AWS Region for Atlas cluster (ClusterRegion)

us-east-1

AWS Region where the Atlas database cluster runs.

MongoDB Atlas instance size (ClusterInstanceSize)

M10

Atlas provides different cluster tiers, each with a default storage capacity and RAM size. The cluster you choose is used for all data-bearing hosts in your cluster tier (see https://docs.atlas.mongodb.com/reference/amazon-aws/#amazon-aws).

Table 11. AWS Quick Start configuration
Parameter label (name) Default value Description

Quick Start S3 bucket name (QSS3BucketName)

aws-quickstart

S3 bucket name for the Quick Start assets. This string can include numbers, lowercase letters, uppercase letters, and hyphens (-). It cannot start or end with a hyphen (-).

Quick Start S3 key prefix (QSS3KeyPrefix)

quickstart-mongodb-atlas/

S3 key prefix for the Quick Start assets. Quick Start key prefix can include numbers, lowercase letters, uppercase letters, hyphens (-), and forward slashes (/).

Quick Start S3 bucket Region (QSS3BucketRegion)

us-east-1

AWS Region where the Quick Start S3 bucket (QSS3BucketName) is hosted. If you use your own bucket, you must specify this value.

Send us feedback

To post feedback, submit feature ideas, or report bugs, use the Issues section of the GitHub repository for this Quick Start. To submit code, see the Quick Start Contributor’s Guide.

Quick Start reference deployments

GitHub repository

Visit our GitHub repository to download the templates and scripts for this Quick Start, to post your comments, and to share your customizations with others.


Notices

This document is provided for informational purposes only. It represents AWS’s current product offerings and practices as of the date of issue of this document, which are subject to change without notice. Customers are responsible for making their own independent assessment of the information in this document and any use of AWS’s products or services, each of which is provided “as is” without warranty of any kind, whether expressed or implied. This document does not create any warranties, representations, contractual commitments, conditions, or assurances from AWS, its affiliates, suppliers, or licensors. The responsibilities and liabilities of AWS to its customers are controlled by AWS agreements, and this document is not part of, nor does it modify, any agreement between AWS and its customers.

The software included with this paper is licensed under the Apache License, version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at http://aws.amazon.com/apache2.0/ or in the accompanying "license" file. This code is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or implied. See the License for specific language governing permissions and limitations.