Resource: aws_sagemaker_model

Provides a SageMaker model resource.

Example Usage

Basic usage:

resource "aws_sagemaker_model" "example" {
  name               = "my-model"
  execution_role_arn = aws_iam_role.example.arn

  primary_container {
    image = data.aws_sagemaker_prebuilt_ecr_image.test.registry_path
  }
}

resource "aws_iam_role" "example" {
  assume_role_policy = data.aws_iam_policy_document.assume_role.json
}

data "aws_iam_policy_document" "assume_role" {
  statement {
    actions = ["sts:AssumeRole"]

    principals {
      type        = "Service"
      identifiers = ["sagemaker.amazonaws.com"]
    }
  }
}

data "aws_sagemaker_prebuilt_ecr_image" "test" {
  repository_name = "kmeans"
}

Argument Reference

This resource supports the following arguments:

The primary_container and container block both support:

Image Config

Repository Auth Config

Model Data Source

S3 Data Source

Inference Execution Config

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Import

In Terraform v1.5.0 and later, use an import block to import models using the name. For example:

import {
  to = aws_sagemaker_model.test_model
  id = "model-foo"
}

Using terraform import, import models using the name. For example:

% terraform import aws_sagemaker_model.test_model model-foo