Skip to Main Content

MongoByte MongoDB Logo

Welcome to the new MongoDB Feedback Portal!

{Improvement: "Your idea"}
We’ve upgraded our system to better capture and act on your feedback.
Your feedback is meaningful and helps us build better products.

141 VOTE
Status Under Consideration
Categories Atlas
Created by Guest
Created on Mar 31, 2020

Create databases and collections via API thorough Terraform

Create databases (DB) and collections via API thorough Terraform after the cluster has been created in Atlas. This would provide the ease of writing and running it in a single script before any data is loaded.
  • Attach files
  • Guest
    Jul 13, 2025
    +1 much needed solution for the enterprise customer
  • Guest
    Jul 11, 2025
    Thanks Anuj, I'll reach out via email.
  • Guest
    Jul 10, 2025
    Hello Nitish, Great to hear from you. Please feel free to connect with me in case of any comments or feedback. I've provided my contact details in last post.
  • Guest
    Jul 10, 2025
    Thank you Anuj for sharing about your provider. We've been using terraform-provider-mongodb for managing our MongoDB users, roles, and indexes in our infrastructure from more than a month. The provider is straightforward to use and handles the core MongoDB resources we need.
  • Guest
    Jul 5, 2025
    If anyone need help to manage Indexes through Terraform, here is the provider feature I have added: registry.terraform.io/providers/megum1n/mongodb/latest It also support user and their roles. In case of any help required, feel free to contact me on https://www.linkedin.com/in/anujtyagi1 or anujajtyagi@gmail.com I will be happy to help, improve in case of any feedback
  • Guest
    Jul 3, 2025
    +1 ask from my enterprise customer!
  • Guest
    Jul 2, 2025
    We manage all our MongoDB Atlas infrastructure using Terraform for consistency, repeatability, and compliance with our IaC standards. The inability to create databases and collections through Terraform breaks this workflow and requires manual intervention or external scripting, which increases the risk of configuration drift and human error. Having support for database and collection creation via Terraform would allow us to fully automate our MongoDB environments and maintain a consistent, version-controlled deployment pipeline across all environments. This would be a valuable enhancement for teams adopting infrastructure as code best practices.
  • Guest
    Jun 19, 2025
    +1 ask from my enterprise customer.
  • Guest
    May 15, 2025
    Hello, I have created a terraform provider to manage MongoDB indexes. It also support users and roles. When you create index, it also will create collections. Feel free to give it a try: https://registry.terraform.io/providers/megum1n/mongodb/latest
  • Guest
    Feb 4, 2025
    There's no resource in terraform-provider-mongodbatlas to create a collection, but there is a resource to create a search index, which requires a collection to be created beforehand. This means that the lifecycle of a DB with a search index cannot be managed entirely in Terraform - I have to do something out-of-process to create the collection (e.g. use the MongoDB client). I can't even do this using the Atlas CLI, much to my chagrin.
  • Guest
    Oct 22, 2024
    That would be really useful.
  • Guest
    Feb 12, 2024
    I've been using a python script with null_resource buried within a module to create databases and indexes as a work around.
  • Guest
    Feb 12, 2024
    Really difficult to make use of the mongodbatlas_event_trigger resource if you want one of type DATABASE and the collection needs to exist, but you can't create the collection using Terraform...
  • Guest
    Oct 30, 2023
    The documentation for the online archive resource states that a collection must already exist in order to enable the online archive feature for it: https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/resources/online_archive Therefore I think it's pretty important to support creating a collection from Terraform, otherwise it's impossible to use the online archive resource as part of a declarative infrastructure-as-code configuration. Instead we have to resort to some sort of flakey script in a Terraform "provisioner" which is an antipattern.
  • Guest
    Oct 20, 2023
    This would fill a painful gap in the dev ops our practices that otherwise Atlas serves quite well.
  • Guest
    Aug 10, 2023
    Set up of indices should not be the responsibility of application code. Set up of indices is an infrastructure task. Managing IAC is commonly considered a critical piece.
  • Guest
    Jul 12, 2023
    Creating a database is core functionality. Im surprised that creating a database isn't available.
  • Guest
    Jul 5, 2023
    Creating a database is core functionality. I'm stunned that creating a database isn't available.
  • Guest
    Apr 13, 2023
    This is one of those features that should be expected from an enterprise product. Not having this creates many challenges with creating search and global shard indexes, since those cannot be created during runtime.
  • Guest
    Mar 9, 2023
    It is a very interesting feature for our organization because we can increase our automation capacity.
  • Load older comments
  • +41