How can i deploy to AWS sagemaker with terraform?

I see on this page, deploying a model to sagemaker is very easy with a few lines of python

This issue is version control and envrironment control. My team is using terraform to manage cloud resources and would like this be setup with terraform and not just some arbitrary python code.

Hi

I used these two pages to help me do that:

in the end my terraform became something like this:

resource "aws_sagemaker_model" "mymodel" {
  name               = "mymodel"
  execution_role_arn = ...

  primary_container {
    image = "763104351884.dkr.ecr.ap-southeast-2.amazonaws.com/huggingface-pytorch-tgi-inference:2.1.1-tgi2.0.0-gpu-py310-cu121-ubuntu22.04-v2.0"
    environment = {
      HF_TASK           = "question-answering"
      HF_MODEL_ID       = "meta-llama/Meta-Llama-3-8B-Instruct"
      HF_API_TOKEN      = "mytoken"
    }
  }
}

hope that helps