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.

Status Submitted
Categories Atlas
Created by Guest
Created on Sep 30, 2022

Adding indexes(Not search index) using terraform

I would like to create mongodb atlas index using terraform. But as of now we can able to create search index in mongodb atlas using terraform. here the expectation is to create normal index using terraform.
  • Attach files
  • Guest
    Jul 10, 2025
    Hello Simon, I will share you module using provider https://registry.terraform.io/providers/megum1n/mongodb/latest that can help you to manage multiple cluster/DB. Feel free to connect https://www.linkedin.com/in/anujtyagi1/
  • Guest
    May 31, 2025
    By now, are there any plans to make creation of (regular/TTL) indexes possible via the MongoDB Atlas Provider like it is for search indexes ? Especially since also the MongoDB Atlas Data API has been deprecated ? Community providers to make this available are not really usable for us as we can't dynamically use this for multiple projects/clusters/databases (these providers accept only 1 cluster URL whereas we can dynamically create multiple projects containing multiple clusters containing multiple databases using the MongoDB Atlas Provider). We would need to create a separate terraform config for each of the clusters to make this work, and that kind of defeats the purpose.
  • Guest
    May 15, 2025
    Hello, I have created a terraform provider to manage MongoDB indexes Feel free to give it a try: https://registry.terraform.io/providers/megum1n/mongodb/latest
  • Guest
    May 14, 2025
    Unfortunately the MongoDB Atlas Data API has since been deprecated. https://www.mongodb.com/docs/atlas/app-services/deprecation/#atlas-data-api-and-https-endpoints-are-deprecated
  • Guest
    Jul 14, 2024
    I must say I was also rather surprised to find out that there is no way to create a regular index on a collection, but it IS possible to create a search index via Terraform. There does seem to be a community plugin (KIABI-OSS/mongodb) that does just that (create an index, no other functionality), but it would be better to have this included in the official MongoDB provider. Bit of a shame to not have this very basic functionality really.
  • Guest
    Jan 25, 2023
    Our infrastructure is been building by Terraform, including MongoDB. It is frustrating to finger out that "index" is not supported currently. We need to work around to using application APIs to create indexes what is not ideal.
  • Guest
    Nov 17, 2022
    That actually makes a lot of sense - we actually already have a provisioning Lambda written in Go to create a number of views used in our application - we can extend this to create the indexes as well.
  • Guest
    Nov 17, 2022
    Thanks Ganesh / Ben. The Terraform MongoDB Atlas Provider as well as the Atlas Administration API (https://www.mongodb.com/docs/atlas/api/atlas-admin-api/) is mainly used to add, edit, or delete administrative objects within Atlas, including projects, users, and database deployments. However, you won't be able to read or write data, including creating Atlas indexes and we have no near term plans to enable this. Instead, suggest you explore the MongoDB Atlas Data API to read and write data, which we recently GA: https://www.mongodb.com/docs/atlas/api/data-api/ Happy to chat more if this does not meet your need, feel free to email me directly at zuhair.ahmed@mongodb.com and we can find time to brainstorm live. Thank you.
  • Guest
    Nov 15, 2022
    Agreed - our entire infrastructure is built out using Terraform - it's an aberration to have to manually create indexes on collections when we can create search indexes using Terraform.