@aws-cdk_aws-sagemaker-alpha.Model

class Model (construct) ๐Ÿ”น

LanguageType name
.NETAmazon.CDK.AWS.Sagemaker.Alpha.Model
Gogithub.com/aws/aws-cdk-go/awscdksagemakeralpha/v2#Model
Javasoftware.amazon.awscdk.services.sagemaker.alpha.Model
Pythonaws_cdk.aws_sagemaker_alpha.Model
TypeScript (source)@aws-cdk/aws-sagemaker-alpha ยป Model

Implements IConstruct, IDependable, IResource, IModel, IGrantable, IConnectable

Defines a SageMaker Model.

Example

import * as sagemaker from '@aws-cdk/aws-sagemaker-alpha';
import * as path from 'path';

const image = sagemaker.ContainerImage.fromAsset(path.join('path', 'to', 'Dockerfile', 'directory'));
const modelData = sagemaker.ModelData.fromAsset(path.join('path', 'to', 'artifact', 'file.tar.gz'));

const model = new sagemaker.Model(this, 'PrimaryContainerModel', {
  containers: [
    {
      image: image,
      modelData: modelData,
    }
  ]
});

Initializer

new Model(scope: Construct, id: string, props?: ModelProps)

Parameters

  • scope Construct
  • id string
  • props ModelProps

Construct Props

NameTypeDescription
allowAllOutbound?๐Ÿ”นbooleanWhether to allow the SageMaker Model to send all network traffic.
containers?๐Ÿ”นContainerDefinition[]Specifies the container definitions for this model, consisting of either a single primary container or an inference pipeline of multiple containers.
modelName?๐Ÿ”นstringName of the SageMaker Model.
role?๐Ÿ”นIRoleThe IAM role that the Amazon SageMaker service assumes.
securityGroups?๐Ÿ”นISecurityGroup[]The security groups to associate to the Model.
vpc?๐Ÿ”นIVpcThe VPC to deploy model containers to.
vpcSubnets?๐Ÿ”นSubnetSelectionThe VPC subnets to use when deploying model containers.

allowAllOutbound?๐Ÿ”น

Type: boolean (optional, default: true)

Whether to allow the SageMaker Model to send all network traffic.

If set to false, you must individually add traffic rules to allow the SageMaker Model to connect to network targets.

Only used if 'vpc' is supplied.


containers?๐Ÿ”น

Type: ContainerDefinition[] (optional, default: none)

Specifies the container definitions for this model, consisting of either a single primary container or an inference pipeline of multiple containers.


modelName?๐Ÿ”น

Type: string (optional, default: AWS CloudFormation generates a unique physical ID and uses that ID for the model's name.)

Name of the SageMaker Model.


role?๐Ÿ”น

Type: IRole (optional, default: a new IAM role will be created with the AmazonSageMakerFullAccess policy attached.)

The IAM role that the Amazon SageMaker service assumes.

See also: https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-roles.html#sagemaker-roles-createmodel-perms


securityGroups?๐Ÿ”น

Type: ISecurityGroup[] (optional, default: A security group will be automatically created if 'vpc' is supplied)

The security groups to associate to the Model.

If no security groups are provided and 'vpc' is configured, one security group will be created automatically.


vpc?๐Ÿ”น

Type: IVpc (optional, default: none)

The VPC to deploy model containers to.


vpcSubnets?๐Ÿ”น

Type: SubnetSelection (optional, default: none)

The VPC subnets to use when deploying model containers.

Properties

NameTypeDescription
connections๐Ÿ”นConnectionsAn accessor for the Connections object that will fail if this Model does not have a VPC configured.
env๐Ÿ”นResourceEnvironmentThe environment this resource belongs to.
grantPrincipal๐Ÿ”นIPrincipalThe principal this Model is running as.
modelArn๐Ÿ”นstringReturns the ARN of this model.
modelName๐Ÿ”นstringReturns the name of the model.
node๐Ÿ”นNodeThe tree node.
stack๐Ÿ”นStackThe stack in which this resource is defined.
role?๐Ÿ”นIRoleExecution role for SageMaker Model.

connections๐Ÿ”น

Type: Connections

An accessor for the Connections object that will fail if this Model does not have a VPC configured.


env๐Ÿ”น

Type: ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.


grantPrincipal๐Ÿ”น

Type: IPrincipal

The principal this Model is running as.


modelArn๐Ÿ”น

Type: string

Returns the ARN of this model.


modelName๐Ÿ”น

Type: string

Returns the name of the model.


node๐Ÿ”น

Type: Node

The tree node.


stack๐Ÿ”น

Type: Stack

The stack in which this resource is defined.


role?๐Ÿ”น

Type: IRole (optional)

Execution role for SageMaker Model.

Methods

NameDescription
addContainer(container)๐Ÿ”นAdd containers to the model.
addToRolePolicy(statement)๐Ÿ”นAdds a statement to the IAM role assumed by the instance.
applyRemovalPolicy(policy)๐Ÿ”นApply the given removal policy to this resource.
toString()๐Ÿ”นReturns a string representation of this construct.
static fromModelArn(scope, id, modelArn)๐Ÿ”นImports a Model defined either outside the CDK or in a different CDK stack.
static fromModelAttributes(scope, id, attrs)๐Ÿ”นImports a Model defined either outside the CDK or in a different CDK stack.
static fromModelName(scope, id, modelName)๐Ÿ”นImports a Model defined either outside the CDK or in a different CDK stack.

addContainer(container)๐Ÿ”น

public addContainer(container: ContainerDefinition): void

Parameters

  • container ContainerDefinition โ€” The container definition to add.

Add containers to the model.


addToRolePolicy(statement)๐Ÿ”น

public addToRolePolicy(statement: PolicyStatement): void

Parameters

  • statement PolicyStatement

Adds a statement to the IAM role assumed by the instance.


applyRemovalPolicy(policy)๐Ÿ”น

public applyRemovalPolicy(policy: RemovalPolicy): void

Parameters

  • policy RemovalPolicy

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).


toString()๐Ÿ”น

public toString(): string

Returns

  • string

Returns a string representation of this construct.


static fromModelArn(scope, id, modelArn)๐Ÿ”น

public static fromModelArn(scope: Construct, id: string, modelArn: string): IModel

Parameters

  • scope Construct โ€” the Construct scope.
  • id string โ€” the resource id.
  • modelArn string โ€” the ARN of the model.

Returns

  • IModel

Imports a Model defined either outside the CDK or in a different CDK stack.


static fromModelAttributes(scope, id, attrs)๐Ÿ”น

public static fromModelAttributes(scope: Construct, id: string, attrs: ModelAttributes): IModel

Parameters

  • scope Construct โ€” the Construct scope.
  • id string โ€” the resource id.
  • attrs ModelAttributes โ€” the attributes of the model to import.

Returns

  • IModel

Imports a Model defined either outside the CDK or in a different CDK stack.


static fromModelName(scope, id, modelName)๐Ÿ”น

public static fromModelName(scope: Construct, id: string, modelName: string): IModel

Parameters

  • scope Construct โ€” the Construct scope.
  • id string โ€” the resource id.
  • modelName string โ€” the name of the model.

Returns

  • IModel

Imports a Model defined either outside the CDK or in a different CDK stack.