Resource: aws_sagemaker_domain

Provides a SageMaker Domain resource.

Example Usage

Basic usage

resource "aws_sagemaker_domain" "example" {
  domain_name = "example"
  auth_mode   = "IAM"
  vpc_id      = aws_vpc.example.id
  subnet_ids  = [aws_subnet.example.id]

  default_user_settings {
    execution_role = aws_iam_role.example.arn
  }
}

resource "aws_iam_role" "example" {
  name               = "example"
  path               = "/"
  assume_role_policy = data.aws_iam_policy_document.example.json
}

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

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

Using Custom Images

resource "aws_sagemaker_image" "example" {
  image_name = "example"
  role_arn   = aws_iam_role.example.arn
}

resource "aws_sagemaker_app_image_config" "example" {
  app_image_config_name = "example"

  kernel_gateway_image_config {
    kernel_spec {
      name = "example"
    }
  }
}

resource "aws_sagemaker_image_version" "example" {
  image_name = aws_sagemaker_image.example.id
  base_image = "base-image"
}

resource "aws_sagemaker_domain" "example" {
  domain_name = "example"
  auth_mode   = "IAM"
  vpc_id      = aws_vpc.example.id
  subnet_ids  = [aws_subnet.example.id]

  default_user_settings {
    execution_role = aws_iam_role.example.arn

    kernel_gateway_app_settings {
      custom_image {
        app_image_config_name = aws_sagemaker_app_image_config.example.app_image_config_name
        image_name            = aws_sagemaker_image_version.example.image_name
      }
    }
  }
}

Argument Reference

The following arguments are required:

The following arguments are optional:

default_space_settings Block

default_user_settings Block

space_storage_settings Block

custom_file_system_config Block

custom_posix_user_config Block

r_studio_server_pro_app_settings Block

canvas_app_settings Block

identity_provider_oauth_settings Block
direct_deploy_settings Block
kendra_settings Block
model_register_settings Block
time_series_forecasting_settings Block
workspace_settings Block

sharing_settings Block

tensor_board_app_settings Block

kernel_gateway_app_settings Block

jupyter_server_app_settings Block

jupyter_lab_app_settings Block

code_editor_app_settings Block

code_repository Block
default_resource_spec Block

r_session_app_settings Block

custom_image Block
default_ebs_storage_settings Block
efs_file_system_config Block

domain_settings Block

r_studio_server_pro_domain_settings Block

retention_policy Block

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 SageMaker Domains using the id. For example:

import {
  to = aws_sagemaker_domain.test_domain
  id = "d-8jgsjtilstu8"
}

Using terraform import, import SageMaker Domains using the id. For example:

% terraform import aws_sagemaker_domain.test_domain d-8jgsjtilstu8