MongoDB & HashiCorp Terraform

Increase developer velocity and release new products and features faster by integrating MongoDB Atlas into your continuous delivery workflow. The HashiCorp Terraform MongoDB Atlas Provider automates your data infrastructure deployment by making it easy to provision, manage, and control Atlas configurations as code on any cloud provider through HashiCorp Terraform.

Simplify infrastructure management

Fully automated deployment of MongoDB Atlas clusters through code, including provisioning, access controls, networking, encryption at rest, backups, and more.

Standardize and control workflows

Deploy MongoDB Atlas in the same workflow as other resources and ensure consistency across teams by creating modules for standard configurations in Terraform.

Cloud-first and platform agnostic

Whether you run on a single cloud or multi-cloud, HashiCorp Terraform and MongoDB Atlas make it easy to provision infrastructure with support for AWS, Azure, and GCP.

How to use MongoDB Atlas and HashiCorp Terraform

The HashiCorp Terraform MongoDB Atlas Provider is the official plugin approved and tested by HashiCorp that enables you to add MongoDB Atlas to your Terraform environment. You can then create, manage, and update your Atlas projects through Terraform.

Sign up for MongoDB Atlas

If you don’t already use MongoDB Atlas, sign up for an account today. Distributed and secure by default, MongoDB Atlas is a global cloud database service available on AWS, Azure, and Google Cloud.

Get Started →

Configure HashiCorp Terraform

To use the HashiCorp Terraform MongoDB Atlas Provider, you will first need to configure it with the proper credentials. Provide your credentials for authentication via static credentials or environment variables, then simply define your desired Atlas resources.

See Examples →

Deploy!

Once you’ve created your MongoDB Atlas account and configured your Terraform environment, you’re all set!

View Docs →

MongoDB Atlas & HashiCorp Terraform FAQ

What is MongoDB Atlas?

MongoDB Atlas is the global cloud database service for modern applications. Deploy fully managed MongoDB across AWS, Azure, or Google Cloud with best-in-class automation and proven practices that guarantee availability, scalability, and compliance with security standards. Use MongoDB’s robust ecosystem of drivers, integrations, and tools to build faster and spend less time on operations and database administration.

With Atlas, you can easily deploy, update, and manage MongoDB configurations as code through Terraform.

Can I use HashiCorp Terraform with my existing MongoDB database?

Currently, there is no official plugin for using HashiCorp Terraform with non-Atlas MongoDB deployments. If you already run MongoDB on the cloud, in your data center, or with a third-party database-as-a-service provider, learn how you can migrate to MongoDB Atlas to use the HashiCorp Terraform MongoDB Atlas Provider.

What is HashiCorp Terraform?

HashiCorp Terraform is a tool which provides a foundation for cloud infrastructure automation using infrastructure as code for provisioning and compliance in the cloud operating model. Operators can easily provision and manage any infrastructure with one workflow and on-demand using a library of approved infrastructure modules.

Terraform is offered both as an open source and enterprise solution, with the enterprise product building on the open source to address organizational challenges and complexity.

Who is HashiCorp?

HashiCorp is a cloud infrastructure automation software company whose suite of tools enable organizations to provision, secure, connect, and run any infrastructure for any application. HashiCorp is the creator of the tools Vagrant, Packer, Terraform, Vault, Consul and Nomad. The HashiCorp suite unlocks the cloud operating model for every business and enables their digital transformation strategies to succeed.

What is a Terraform provider?

In order for Terraform to create, manage, and update infrastructure resources, customers must use a Terraform provider. A provider is a plugin responsible for understanding both the Terraform and provider’s APIs and exposing the provider’s resources. Providers are generally an IaaS (e.g., AWS, Azure, GCP), PaaS (e.g., Heroku), or SaaS service (e.g., CloudFlare).

Terraform users can opt to use either a verified provider or a community provider. The former are primarily supported by the vendor in close collaboration with HashiCorp, who verifies the provider and regularly tests it. Verified providers that are configured by the user in their code are automatically loaded when Terraform is initialized. The latter can be created by anyone in the community and must be installed manually.

What resources are supported by the HashiCorp Terraform MongoDB Atlas Provider?

The HashiCorp Terraform MongoDB Atlas Provider (0.4.0) currently supports the following resources: clusters, project IP whitelisting (with support for AWS security groups), network peering, AWS PrivateLink (for AWS only), teams, custom roles, encryption at rest, auditing, alerts, maintenance windows, database users, and X.509 certificate-based database authentication.

Who is supporting the HashiCorp Terraform MongoDB Atlas Provider?

The HashiCorp Terraform MongoDB Atlas Provider code is hosted on the official Terraform GitHub repo and community members are welcome to contribute to the project and submit bug reports and fixes. MongoDB will maintain and update the Terraform MongoDB Atlas Provider. The MongoDB Cloud Support team will be available to help troubleshoot any issues related to MongoDB Atlas and the Provider as part of a customer’s current support contract for Atlas Developer plans and higher.

I’m interested in a resource that’s not currently supported by the Terraform MongoDB Atlas Provider. What do I do?

Let us know! Click here to leave feedback.

Does MongoDB Atlas integrate with other Infrastructure as Code (IaC) tools like Chef, Puppet, Ansible, or CloudFormation?

There are no official integrations between MongoDB Atlas and other infrastructure as code tools such as Chef, Puppet, Ansible, or CloudFormation. However, customers are welcome to use the Atlas public API to connect to Atlas resources.

HashiCorp Terraform is often listed alongside Chef, Puppet, Ansible, CloudFormation, and other tools under the category of infrastructure as code. However, the IaC label actually includes several distinct capabilities, each with different approaches and implications.

The biggest difference is that Chef, Puppet, and Ansible are configuration management tools, which means they primarily install and manage software on existing servers. HashiCorp Terraform and CloudFormation, on the other hand, are primarily provisioning tools, which means they provision the servers themselves, as well as other parts of your infrastructure like load balancers, databases, and networking configurations.

Companies may use several infrastructure as code tools together to automate provisioning, configuration management, server templating, and orchestration. For example, some use HashiCorp Terraform, Packer, Docker, and Kubernetes together for provisioning, server templating, and orchestration. This article by Gruntwork offers a great summary of the key differences between infrastructure as code tools and common combinations that companies use.

Organizations using Kubernetes can use the MongoDB Atlas Open Service Broker to deploy, manage, and access Atlas on their cloud platform of choice.

Ready to get started?

Launch a new cluster or migrate to MongoDB Atlas with zero downtime.