Skip to content
GitHubXDiscord

InferenceComponent

The InferenceComponent resource allows you to manage AWS SageMaker InferenceComponents for deploying machine learning models and serving predictions.

Create a basic InferenceComponent with required properties and one optional property:

import AWS from "alchemy/aws/control";
const inferenceComponent = await AWS.SageMaker.InferenceComponent("basicInferenceComponent", {
EndpointName: "my-endpoint",
Specification: {
ContentType: "application/json",
InputPath: "/input",
OutputPath: "/output"
},
VariantName: "AllTraffic" // Common optional property
});

Configure an InferenceComponent with additional options such as runtime configuration and deployment settings:

const advancedInferenceComponent = await AWS.SageMaker.InferenceComponent("advancedInferenceComponent", {
EndpointName: "my-endpoint",
Specification: {
ContentType: "application/json",
InputPath: "/input",
OutputPath: "/output"
},
RuntimeConfig: {
Environment: {
LOG_LEVEL: "DEBUG"
}
},
DeploymentConfig: {
AutoRollbackConfiguration: {
Alarms: [
{
AlarmName: "HighErrorRate",
AlarmType: "CLOUDWATCH",
Interval: 60
}
]
}
}
});

Create an InferenceComponent and assign tags for better resource management:

const taggedInferenceComponent = await AWS.SageMaker.InferenceComponent("taggedInferenceComponent", {
EndpointName: "my-endpoint",
Specification: {
ContentType: "application/json",
InputPath: "/input",
OutputPath: "/output"
},
Tags: [
{ Key: "Project", Value: "ImageRecognition" },
{ Key: "Environment", Value: "Production" }
]
});

If you want to adopt an existing InferenceComponent instead of creating a new one, you can set the adopt property to true:

const adoptedInferenceComponent = await AWS.SageMaker.InferenceComponent("adoptedInferenceComponent", {
EndpointName: "existing-endpoint",
Specification: {
ContentType: "application/json",
InputPath: "/input",
OutputPath: "/output"
},
adopt: true // Adopt existing resource
});