# How can i deploy to AWS sagemaker with terraform?

**URL:** <https://discuss.huggingface.co/t/how-can-i-deploy-to-aws-sagemaker-with-terraform/77131>\
**Category:** Amazon SageMaker\
**Created:** [March 12, 2024, 7:08pm UTC](https://discuss.huggingface.co/t/how-can-i-deploy-to-aws-sagemaker-with-terraform/77131 "2024-03-12T19:08:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mechanistcodes](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@mechanistcodes](https://discuss.huggingface.co/u/mechanistcodes)\
**Post date:** [March 12, 2024, 7:08pm UTC](https://discuss.huggingface.co/t/how-can-i-deploy-to-aws-sagemaker-with-terraform/77131/1 "2024-03-12T19:08:17Z")

</div>

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

> **[Deploy models to Amazon SageMaker](https://huggingface.co/docs/sagemaker/en/inference)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

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.

---

<div class="post-metadata">

**Author:** ![absn](https://avatars.discourse-cdn.com/v4/letter/a/4bbf92/32.png) [@absn](https://discuss.huggingface.co/u/absn)\
**Post date:** [May 23, 2024, 11:28pm UTC](https://discuss.huggingface.co/t/how-can-i-deploy-to-aws-sagemaker-with-terraform/77131/2 "2024-05-23T23:28:02Z")

</div>

Hi

I used these two pages to help me do that:

> <https://github.com/philschmid/terraform-aws-sagemaker-huggingface/blob/v0.9.0/main.tf>

> **[Deploy Llama 2 7B/13B/70B on Amazon SageMaker](https://www.philschmid.de/sagemaker-llama-llm)**
>
> Learn how to deploy Llama 2 models (7B - 70B) to Amazon SageMaker using the Hugging Face LLM Inference DLC.

in the end my terraform became something like this:

```auto
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
