CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-pulumi--aws

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources with infrastructure-as-code.

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

sagemaker.mddocs/ml/

Amazon SageMaker

Amazon SageMaker is a fully managed machine learning service that enables developers and data scientists to build, train, and deploy ML models quickly.

Package

import * as aws from "@pulumi/aws";
import * as sagemaker from "@pulumi/aws/sagemaker";

Key Resources

Notebook Instance

Jupyter notebook environment for ML development.

const notebookInstance = new aws.sagemaker.NotebookInstance("ml-notebook", {
    name: "my-ml-notebook",
    roleArn: sagemakerRole.arn,
    instanceType: "ml.t3.medium",
    volumeSizeInGb: 20,
    directInternetAccess: "Enabled",
    tags: {
        Environment: "development",
    },
});

Model

Define a trained ML model.

const model = new aws.sagemaker.Model("prediction-model", {
    name: "my-prediction-model",
    executionRoleArn: sagemakerRole.arn,
    primaryContainer: {
        image: "12345678.dkr.ecr.us-west-2.amazonaws.com/my-model:latest",
        modelDataUrl: pulumi.interpolate`s3://${modelBucket.id}/model.tar.gz`,
    },
    tags: {
        Model: "prediction",
    },
});

Endpoint Configuration

Configuration for model endpoint.

const endpointConfig = new aws.sagemaker.EndpointConfiguration("endpoint-config", {
    name: "my-endpoint-config",
    productionVariants: [{
        variantName: "default",
        modelName: model.name,
        initialInstanceCount: 1,
        instanceType: "ml.t2.medium",
    }],
    tags: {
        Environment: "production",
    },
});

Endpoint

Deploy model for inference.

const endpoint = new aws.sagemaker.Endpoint("inference-endpoint", {
    name: "my-inference-endpoint",
    endpointConfigName: endpointConfig.name,
    tags: {
        Application: "ml-inference",
    },
});

Common Patterns

Training Job

const trainingJob = new aws.sagemaker.TrainingJob("training", {
    name: "model-training-job",
    roleArn: sagemakerRole.arn,
    algorithmSpecification: {
        trainingImage: "12345678.dkr.ecr.us-west-2.amazonaws.com/xgboost:latest",
        trainingInputMode: "File",
    },
    inputDataConfig: [{
        channelName: "training",
        dataSource: {
            s3DataSource: {
                s3DataType: "S3Prefix",
                s3Uri: pulumi.interpolate`s3://${dataBucket.id}/training/`,
                s3DataDistributionType: "FullyReplicated",
            },
        },
        contentType: "text/csv",
    }],
    outputDataConfig: {
        s3OutputPath: pulumi.interpolate`s3://${modelBucket.id}/output/`,
    },
    resourceConfig: {
        instanceType: "ml.m5.xlarge",
        instanceCount: 1,
        volumeSizeInGb: 50,
    },
    stoppingCondition: {
        maxRuntimeInSeconds: 3600,
    },
    hyperParameters: {
        max_depth: "5",
        eta: "0.2",
        objective: "binary:logistic",
        num_round: "100",
    },
});

AutoML Job

const autoMLJob = new aws.sagemaker.AutoMLJob("automl", {
    name: "automl-job",
    roleArn: sagemakerRole.arn,
    inputDataConfig: [{
        dataSource: {
            s3DataSource: {
                s3DataType: "S3Prefix",
                s3Uri: pulumi.interpolate`s3://${dataBucket.id}/input/`,
            },
        },
        targetAttributeName: "target",
    }],
    outputDataConfig: {
        s3OutputPath: pulumi.interpolate`s3://${outputBucket.id}/automl/`,
    },
    problemType: "BinaryClassification",
    autoMLJobObjective: {
        metricName: "F1",
    },
});

Multi-Model Endpoint

const multiModelEndpointConfig = new aws.sagemaker.EndpointConfiguration("multi-model", {
    name: "multi-model-config",
    productionVariants: [{
        variantName: "default",
        modelName: model.name,
        initialInstanceCount: 1,
        instanceType: "ml.m5.xlarge",
    }],
});

const multiModel = new aws.sagemaker.Model("multi-model", {
    name: "multi-model-endpoint",
    executionRoleArn: sagemakerRole.arn,
    primaryContainer: {
        image: "12345678.dkr.ecr.us-west-2.amazonaws.com/multi-model:latest",
        mode: "MultiModel",
        modelDataUrl: pulumi.interpolate`s3://${modelBucket.id}/models/`,
    },
});

Model with VPC Configuration

const vpcModel = new aws.sagemaker.Model("vpc-model", {
    name: "vpc-model",
    executionRoleArn: sagemakerRole.arn,
    primaryContainer: {
        image: "12345678.dkr.ecr.us-west-2.amazonaws.com/model:latest",
        modelDataUrl: pulumi.interpolate`s3://${modelBucket.id}/model.tar.gz`,
    },
    vpcConfig: {
        subnets: subnetIds,
        securityGroupIds: [securityGroup.id],
    },
});

Key Properties

Notebook Instance Properties

  • name - Notebook instance name
  • roleArn - IAM role ARN
  • instanceType - Instance type (ml.t3.medium, etc.)
  • volumeSizeInGb - EBS volume size

Model Properties

  • name - Model name
  • executionRoleArn - IAM role ARN
  • primaryContainer - Container image and model data
  • vpcConfig - VPC configuration for private inference

Endpoint Properties

  • name - Endpoint name
  • endpointConfigName - Configuration name
  • tags - Resource tags

Output Properties

  • id - Resource identifier
  • arn - Resource ARN
  • name - Resource name

Use Cases

  • Model Development: Interactive ML development with notebooks
  • Model Training: Large-scale distributed training
  • Real-Time Inference: Low-latency predictions
  • Batch Inference: Process large datasets
  • AutoML: Automated model selection and tuning
  • MLOps: End-to-end ML lifecycle management

Related Services

  • S3 - Model and data storage
  • ECR - Container image registry
  • Lambda - Trigger inference
  • Kinesis - Streaming inference data

Install with Tessl CLI

npx tessl i tessl/npm-pulumi--aws@7.16.0

docs

index.md

quickstart.md

README.md

tile.json