Model class
Manages an Amazon SageMaker AI Model.
Example Usage
Basic Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const assumeRole = aws.iam.getPolicyDocument({
statements: [{
principals: [{
type: "Service",
identifiers: ["sagemaker.amazonaws.com"],
}],
actions: ["sts:AssumeRole"],
}],
});
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", {
primaryContainer: {
image: test.then(test => test.registryPath),
},
name: "my-model",
executionRoleArn: exampleRole.arn,
});
import pulumi
import pulumi_aws as aws
assume_role = aws.iam.get_policy_document(statements=[{
"principals": [{
"type": "Service",
"identifiers": ["sagemaker.amazonaws.com"],
}],
"actions": ["sts:AssumeRole"],
}])
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",
primary_container={
"image": test.registry_path,
},
name="my-model",
execution_role_arn=example_role.arn)
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
{
Principals = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
{
Type = "Service",
Identifiers = new[]
{
"sagemaker.amazonaws.com",
},
},
},
Actions = new[]
{
"sts:AssumeRole",
},
},
},
});
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()
{
PrimaryContainer = new Aws.Sagemaker.Inputs.ModelPrimaryContainerArgs
{
Image = test.Apply(getPrebuiltEcrImageResult => getPrebuiltEcrImageResult.RegistryPath),
},
Name = "my-model",
ExecutionRoleArn = exampleRole.Arn,
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/iam"
"github.com/pulumi/pulumi-aws/sdk/v7/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{
{
Principals: []iam.GetPolicyDocumentStatementPrincipal{
{
Type: "Service",
Identifiers: []string{
"sagemaker.amazonaws.com",
},
},
},
Actions: []string{
"sts:AssumeRole",
},
},
},
}, 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{
PrimaryContainer: &sagemaker.ModelPrimaryContainerArgs{
Image: pulumi.String(test.RegistryPath),
},
Name: pulumi.String("my-model"),
ExecutionRoleArn: exampleRole.Arn,
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
data "aws_iam_getpolicydocument" "assumeRole" {
statements {
principals {
type = "Service"
identifiers = ["sagemaker.amazonaws.com"]
}
actions = ["sts:AssumeRole"]
}
}
data "aws_sagemaker_getprebuiltecrimage" "test" {
repository_name = "kmeans"
}
resource "aws_sagemaker_model" "example" {
primary_container = {
image = data.aws_sagemaker_getprebuiltecrimage.test.registry_path
}
name = "my-model"
execution_role_arn = aws_iam_role.example.arn
}
resource "aws_iam_role" "example" {
assume_role_policy = data.aws_iam_getpolicydocument.assumeRole.json
}
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.inputs.GetPolicyDocumentStatementArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementPrincipalArgs;
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.ArrayList;
import java.util.Arrays;
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()
.principals(GetPolicyDocumentStatementPrincipalArgs.builder()
.type("Service")
.identifiers("sagemaker.amazonaws.com")
.build())
.actions("sts:AssumeRole")
.build())
.build());
var exampleRole = new Role("exampleRole", RoleArgs.builder()
.assumeRolePolicy(assumeRole.json())
.build());
final var test = SagemakerFunctions.getPrebuiltEcrImage(GetPrebuiltEcrImageArgs.builder()
.repositoryName("kmeans")
.build());
var example = new Model("example", ModelArgs.builder()
.primaryContainer(ModelPrimaryContainerArgs.builder()
.image(test.registryPath())
.build())
.name("my-model")
.executionRoleArn(exampleRole.arn())
.build());
}
}
resources:
example:
type: aws:sagemaker:Model
properties:
primaryContainer:
image: ${test.registryPath}
name: my-model
executionRoleArn: ${exampleRole.arn}
exampleRole:
type: aws:iam:Role
name: example
properties:
assumeRolePolicy: ${assumeRole.json}
variables:
assumeRole:
fn::invoke:
function: aws:iam:getPolicyDocument
arguments:
statements:
- principals:
- type: Service
identifiers:
- sagemaker.amazonaws.com
actions:
- sts:AssumeRole
test:
fn::invoke:
function: aws:sagemaker:getPrebuiltEcrImage
arguments:
repositoryName: kmeans
Import
Using pulumi import, import models using the name. For example:
$ pulumi import aws:sagemaker/model:Model example model-foo
Constructors
- Model(String name, {ModelArgs? args, CustomResourceOptions? options})
-
Creates a new Model.
nameThe Pulumi resource name.argsArguments used to configure this Model. The set of arguments for Model.optionsResource options controlling this resource's behavior. - Model.reference(String urn)
- Creates a typed reference to an existing Model resource.
Properties
-
arn
↔ Output<
String> -
ARN assigned by AWS to this model.
latefinal
-
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
containers
↔ Output<
List< ModelContainer> ?> -
Specifies containers in the inference pipeline. If not specified, the
primaryContainerargument is required. Fields are documented below.latefinal -
enableNetworkIsolation
↔ Output<
bool?> -
Isolates the model container. No inbound or outbound network calls can be made to or from the model container.
latefinal
-
executionRoleArn
↔ Output<
String> -
A role that SageMaker AI can assume to access model artifacts and docker images for deployment.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
-
inferenceExecutionConfig
↔ Output<
ModelInferenceExecutionConfig> -
Specifies details of how containers in a multi-container endpoint are called. See Inference Execution Config.
latefinal
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
name
↔ Output<
String> -
Name of the model (must be unique). If omitted, the provider will assign a random, unique name.
latefinal
-
primaryContainer
↔ Output<
ModelPrimaryContainer?> -
Primary docker image containing inference code that is used when the model is deployed for predictions. If not specified, the
containerargument is required. Fields are documented below.latefinal -
region
↔ Output<
String> -
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
A map of tags to assign to the resource. .If configured with a provider
defaultTagsconfiguration block present, tags with matching keys will overwrite those defined at the provider-level.latefinal -
A map of tags assigned to the resource, including those inherited from the provider
defaultTagsconfiguration block.latefinal -
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
urn
↔ Output<
String> -
latefinalinherited
-
vpcConfig
↔ Output<
ModelVpcConfig?> -
Specifies the VPC that you want your model to connect to. This configuration is used in hosting services and in batch transform. See VPC Config.
latefinal
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited