Deploy text embedding model via terraform

Hi!

What is the best way to deploy a text embedding model using Terraform? (If you think it should not be done via Terraform at all: What is the best way to automatically deploy a text embedding model to ensure it's always there when elastic is deployed?)

I have created a python script that installs eland, and then uses eland_import_hub_model to install intfloat/multilingual-e5-large to elastic. Then I use null_resource in terraform to execute the script.

However, since we are not controlling our own terraform I am not even sure if python is installed on the machine and figured I probably need a better way of doing that. I need to do it in a way I know will always work regardless where Terraform is running.

Do you have any suggestions?

Hi!

Here are a few thoughts.

First, there are some resources like the teraform elasticstak to help with more common elastic actions w/ terraform that you can take a look at.
At the moment, they don't have specific functionalities within that stack to handle model deployment - but there is a fearture request for it.

In the meantime, if you want to avoid the python dependency question, you can install the model via an API call instead from your terraform:


PUT _ml/trained_models/.multilingual-e5-small
{
  "input": {
	"field_names": ["text_field"]
  }
}

Hope this helps!