Model Args
Provides a SageMaker AI model resource.
Example Usage
Basic usage:
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const assumeRole = aws.iam.getPolicyDocument({
statements: [{
actions: ["sts:AssumeRole"],
principals: [{
type: "Service",
identifiers: ["sagemaker.amazonaws.com"],
}],
}],
});
const exampleRole = new aws.iam.Role("example", {assumeRolePolicy: assumeRole.then(assumeRole => assumeRole.json)});
const test = aws.sagemaker.getPrebuiltEcrImage({
repositoryName: "kmeans",
});
const example = new aws.sagemaker.Model("example", {
name: "my-model",
executionRoleArn: exampleRole.arn,
primaryContainer: {
image: test.then(test => test.registryPath),
},
});
import pulumi
import pulumi_aws as aws
assume_role = aws.iam.get_policy_document(statements=[{
"actions": ["sts:AssumeRole"],
"principals": [{
"type": "Service",
"identifiers": ["sagemaker.amazonaws.com"],
}],
}])
example_role = aws.iam.Role("example", assume_role_policy=assume_role.json)
test = aws.sagemaker.get_prebuilt_ecr_image(repository_name="kmeans")
example = aws.sagemaker.Model("example",
name="my-model",
execution_role_arn=example_role.arn,
primary_container={
"image": test.registry_path,
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var assumeRole = Aws.Iam.GetPolicyDocument.Invoke(new()
{
Statements = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
{
Actions = new[]
{
"sts:AssumeRole",
},
Principals = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
{
Type = "Service",
Identifiers = new[]
{
"sagemaker.amazonaws.com",
},
},
},
},
},
});
var exampleRole = new Aws.Iam.Role("example", new()
{
AssumeRolePolicy = assumeRole.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
});
var test = Aws.Sagemaker.GetPrebuiltEcrImage.Invoke(new()
{
RepositoryName = "kmeans",
});
var example = new Aws.Sagemaker.Model("example", new()
{
Name = "my-model",
ExecutionRoleArn = exampleRole.Arn,
PrimaryContainer = new Aws.Sagemaker.Inputs.ModelPrimaryContainerArgs
{
Image = test.Apply(getPrebuiltEcrImageResult => getPrebuiltEcrImageResult.RegistryPath),
},
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/sagemaker"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
assumeRole, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
Statements: []iam.GetPolicyDocumentStatement{
{
Actions: []string{
"sts:AssumeRole",
},
Principals: []iam.GetPolicyDocumentStatementPrincipal{
{
Type: "Service",
Identifiers: []string{
"sagemaker.amazonaws.com",
},
},
},
},
},
}, nil)
if err != nil {
return err
}
exampleRole, err := iam.NewRole(ctx, "example", &iam.RoleArgs{
AssumeRolePolicy: pulumi.String(assumeRole.Json),
})
if err != nil {
return err
}
test, err := sagemaker.GetPrebuiltEcrImage(ctx, &sagemaker.GetPrebuiltEcrImageArgs{
RepositoryName: "kmeans",
}, nil)
if err != nil {
return err
}
_, err = sagemaker.NewModel(ctx, "example", &sagemaker.ModelArgs{
Name: pulumi.String("my-model"),
ExecutionRoleArn: exampleRole.Arn,
PrimaryContainer: &sagemaker.ModelPrimaryContainerArgs{
Image: pulumi.String(test.RegistryPath),
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.aws.iam.Role;
import com.pulumi.aws.iam.RoleArgs;
import com.pulumi.aws.sagemaker.SagemakerFunctions;
import com.pulumi.aws.sagemaker.inputs.GetPrebuiltEcrImageArgs;
import com.pulumi.aws.sagemaker.Model;
import com.pulumi.aws.sagemaker.ModelArgs;
import com.pulumi.aws.sagemaker.inputs.ModelPrimaryContainerArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var assumeRole = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
.statements(GetPolicyDocumentStatementArgs.builder()
.actions("sts:AssumeRole")
.principals(GetPolicyDocumentStatementPrincipalArgs.builder()
.type("Service")
.identifiers("sagemaker.amazonaws.com")
.build())
.build())
.build());
var exampleRole = new Role("exampleRole", RoleArgs.builder()
.assumeRolePolicy(assumeRole.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult.json()))
.build());
final var test = SagemakerFunctions.getPrebuiltEcrImage(GetPrebuiltEcrImageArgs.builder()
.repositoryName("kmeans")
.build());
var example = new Model("example", ModelArgs.builder()
.name("my-model")
.executionRoleArn(exampleRole.arn())
.primaryContainer(ModelPrimaryContainerArgs.builder()
.image(test.applyValue(getPrebuiltEcrImageResult -> getPrebuiltEcrImageResult.registryPath()))
.build())
.build());
}
}
resources:
example:
type: aws:sagemaker:Model
properties:
name: my-model
executionRoleArn: ${exampleRole.arn}
primaryContainer:
image: ${test.registryPath}
exampleRole:
type: aws:iam:Role
name: example
properties:
assumeRolePolicy: ${assumeRole.json}
variables:
assumeRole:
fn::invoke:
function: aws:iam:getPolicyDocument
arguments:
statements:
- actions:
- sts:AssumeRole
principals:
- type: Service
identifiers:
- sagemaker.amazonaws.com
test:
fn::invoke:
function: aws:sagemaker:getPrebuiltEcrImage
arguments:
repositoryName: kmeans
Inference Execution Config
mode
- (Required) How containers in a multi-container are run. The following values are validSerial
andDirect
.
Import
Using pulumi import
, import models using the name
. For example:
$ pulumi import aws:sagemaker/model:Model test_model model-foo
Constructors
Properties
Specifies containers in the inference pipeline. If not specified, the primary_container
argument is required. Fields are documented below.
Isolates the model container. No inbound or outbound network calls can be made to or from the model container.
A role that SageMaker AI can assume to access model artifacts and docker images for deployment.
Specifies details of how containers in a multi-container endpoint are called. see Inference Execution Config.
The primary docker image containing inference code that is used when the model is deployed for predictions. If not specified, the container
argument is required. Fields are documented below.
Specifies the VPC that you want your model to connect to. VpcConfig is used in hosting services and in batch transform.