class Model (construct)
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.Sagemaker.Alpha.Model |
![]() | github.com/aws/aws-cdk-go/awscdksagemakeralpha/v2#Model |
![]() | software.amazon.awscdk.services.sagemaker.alpha.Model |
![]() | aws_cdk.aws_sagemaker_alpha.Model |
![]() | @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';
declare const image: sagemaker.ContainerImage;
declare const modelData: sagemaker.ModelData;
const model = new sagemaker.Model(this, 'ContainerModel', {
containers: [
{
image,
modelData,
}
],
networkIsolation: true,
});
Initializer
new Model(scope: Construct, id: string, props?: ModelProps)
Parameters
- scope
Construct
- id
string
- props
Model
Props
Construct Props
Name | Type | Description |
---|---|---|
allow | boolean | Whether to allow the SageMaker Model to send all network traffic. |
containers? | Container [] | Specifies the container definitions for this model, consisting of either a single primary container or an inference pipeline of multiple containers. |
model | string | Name of the SageMaker Model. |
network | boolean | Whether to enable network isolation for the model container. |
role? | IRole | The IAM role that the Amazon SageMaker service assumes. |
security | ISecurity [] | The security groups to associate to the Model. |
vpc? | IVpc | The VPC to deploy model containers to. |
vpc | Subnet | The 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:
Container
[]
(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.
networkIsolation?
Type:
boolean
(optional, default: false)
Whether to enable network isolation for the model container.
When enabled, no inbound or outbound network calls can be made to or from the model container.
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.
securityGroups?
Type:
ISecurity
[]
(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:
Subnet
(optional, default: none)
The VPC subnets to use when deploying model containers.
Properties
Name | Type | Description |
---|---|---|
connections | Connections | An accessor for the Connections object that will fail if this Model does not have a VPC configured. |
env | Resource | The environment this resource belongs to. |
grant | IPrincipal | The principal this Model is running as. |
model | string | Returns the ARN of this model. |
model | string | Returns the name of the model. |
node | Node | The tree node. |
stack | Stack | The stack in which this resource is defined. |
role? | IRole | Execution 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:
Resource
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
Name | Description |
---|---|
add | Add containers to the model. |
add | Adds a statement to the IAM role assumed by the instance. |
apply | Apply the given removal policy to this resource. |
to | Returns a string representation of this construct. |
static from | Imports a Model defined either outside the CDK or in a different CDK stack. |
static from | Imports a Model defined either outside the CDK or in a different CDK stack. |
static from | Imports a Model defined either outside the CDK or in a different CDK stack. |
addContainer(container)
public addContainer(container: ContainerDefinition): void
Parameters
- container
Container
โ The container definition to add.Definition
Add containers to the model.
addToRolePolicy(statement)
public addToRolePolicy(statement: PolicyStatement): void
Parameters
- statement
Policy
Statement
Adds a statement to the IAM role assumed by the instance.
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
Policy
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
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
Model
โ the attributes of the model to import.Attributes
Returns
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
Imports a Model defined either outside the CDK or in a different CDK stack.