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.
-
Simon commented
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. -
Tan Hoai Nguyen commented
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.
-
Ben Giddins commented
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.
-
AdminZuhair (Admin, MongoDB) commented
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.
(Edited by admin) -
Ben Giddins commented
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.