in src/modules/insights/cdk/lib/iot-twin-maker-sagemaker-stack.ts [194:246]
private createAnomalyDetectionEndpoint(
executionRole: Role,
anomalyDetectionModelAsset: assets.Asset,
region: string
): CfnEndpoint {
const sageMakerModel = new CfnModel(
this,
"SageMakerAnomalyDetectionModel",
{
executionRoleArn: executionRole.roleArn,
modelName: `Anomaly-Detection-Model-${new Date().valueOf()}`,
containers: [
{
image: this.getRandomCutForestDockerRegistrationPath(region),
imageConfig: { repositoryAccessMode: "Platform" },
mode: "SingleModel",
modelDataUrl: anomalyDetectionModelAsset.httpUrl,
},
],
}
);
sageMakerModel.node.addDependency(
anomalyDetectionModelAsset,
executionRole
);
const sageMakerEndpointConfig = new CfnEndpointConfig(
this,
"SagemakerAnomalyDetectionEndpointConfig",
{
productionVariants: [
{
initialInstanceCount: 1.0,
initialVariantWeight: 1.0,
instanceType: "ml.m4.xlarge",
modelName: sageMakerModel.modelName!,
variantName: "AllTraffic", // keep variant name constant
},
],
}
);
sageMakerEndpointConfig.node.addDependency(sageMakerModel);
const sageMakerEndpoint = new CfnEndpoint(
this,
"AnomalyDetectionEndpoint",
{
endpointConfigName: sageMakerEndpointConfig.attrEndpointConfigName!,
}
);
sageMakerEndpoint.node.addDependency(sageMakerEndpointConfig);
return sageMakerEndpoint;
}