Experimental
@aws-cdk/aws-sagemaker-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
Model L2 construct
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,
});
import aws_cdk.aws_sagemaker_alpha as sagemaker
# image: sagemaker.ContainerImage
# model_data: sagemaker.ModelData
model = sagemaker.Model(self, "ContainerModel",
containers=[sagemaker.ContainerDefinition(
image=image,
model_data=model_data
)
],
network_isolation=True
)
import software.amazon.awscdk.services.sagemaker.alpha.*;
ContainerImage image;
ModelData modelData;
Model model = Model.Builder.create(this, "ContainerModel")
.containers(List.of(ContainerDefinition.builder()
.image(image)
.modelData(modelData)
.build()))
.networkIsolation(true)
.build();
// Install: dotnet add package Amazon.CDK.AWS.Sagemaker.Alpha
using Amazon.CDK.AWS.Sagemaker.Alpha;
ContainerImage image;
ModelData modelData;
var model = new Model(this, "ContainerModel", new ModelProps {
Containers = new [] { new ContainerDefinition {
Image = image,
ModelData = modelData
} },
NetworkIsolation = true
});
// Install: go get github.com/aws/aws-cdk-go/awscdksagemakeralpha/v2
import sagemaker "github.com/aws/aws-cdk-go/awscdksagemakeralpha"
var image ContainerImage
var modelData ModelData
model := sagemaker.NewModel(this, jsii.String("ContainerModel"), &ModelProps{
Containers: []ContainerDefinition{
&ContainerDefinition{
Image: *Image,
ModelData: *ModelData,
},
},
NetworkIsolation: jsii.Boolean(true),
})
Initializer
new Model(scope: Construct, id: string, props?: ModelProps)
Model(scope: Construct, id: str, props: typing.Optional[ModelProps] = None)
new Model(Construct scope, String id, ModelProps props)
new Model(Construct scope, string id, ModelProps? props = null)
NewModel(Scope Construct, Id *string, Props ModelProps)
Construct Props
allowAllOutboundbooleanallow_all_outboundboolallowAllOutboundBooleanAllowAllOutboundboolAllowAllOutbound*bool= true#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.
containersContainerDefinition[]containerstyping.List[ContainerDefinition]containersList<ContainerDefinition>ContainersContainerDefinition[]Containers*[]ContainerDefinition= none#modelNamestringmodel_namestrmodelNameStringModelNamestringModelName*string= AWS CloudFormation generates a u…#default
Default: AWS CloudFormation generates a unique physical ID and uses that ID for the model's name.
networkIsolationbooleannetwork_isolationboolnetworkIsolationBooleanNetworkIsolationboolNetworkIsolation*bool= false#When enabled, no inbound or outbound network calls can be made to or from the model container.
default
Default: a new IAM role will be created with the AmazonSageMakerFullAccess policy attached.
securityGroupsISecurityGroup[]security_groupstyping.List[ISecurityGroup]securityGroupsList<ISecurityGroup>SecurityGroupsISecurityGroup[]SecurityGroups*[]ISecurityGroup= A security group will be automat…#If no security groups are provided and 'vpc' is configured, one security group will be created automatically.
default
Default: A security group will be automatically created if 'vpc' is supplied
vpcSubnetsSubnetSelectionvpc_subnetsSubnetSelectionvpcSubnetsSubnetSelectionVpcSubnetsSubnetSelectionVpcSubnetsSubnetSelection= none#Properties
connectionsConnectionsconnectionsConnectionsconnectionsConnectionsConnectionsConnectionsConnectionsConnectionsrequired#envResourceEnvironmentenvResourceEnvironmentenvResourceEnvironmentEnvResourceEnvironmentEnvResourceEnvironmentrequired#notes
For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.
grantPrincipalIPrincipalgrant_principalIPrincipalgrantPrincipalIPrincipalGrantPrincipalIPrincipalGrantPrincipalIPrincipalrequired#PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#Methods
addContainer(container: ContainerDefinition): voiddef add_container(self, container: ContainerDefinition) -> Nonepublic void addContainer(ContainerDefinition container)public void AddContainer(ContainerDefinition container)func AddContainer(Container ContainerDefinition)#1 parameter
Parameters
containercontainercontainercontainerContainer— The container definition to add.
addToRolePolicy(statement: PolicyStatement): voiddef add_to_role_policy(self, statement: PolicyStatement) -> Nonepublic void addToRolePolicy(PolicyStatement statement)public void AddToRolePolicy(PolicyStatement statement)func AddToRolePolicy(Statement PolicyStatement)#applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#notes · 1 parameter
When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.
Parameters
strengthstrengthstrengthstrengthStrength— - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#notes
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).
fromModelArn(scope: Construct, id: string, modelArn: string): IModel@staticmethod def from_model_arn(scope: Construct, id: str, model_arn: str) -> IModelpublic static IModel fromModelArn(Construct scope, String id, String modelArn)public static IModel FromModelArn(Construct scope, string id, string modelArn)func FromModelArn(Scope Construct, Id *string, ModelArn *string) IModelstatic#3 parameters
Parameters
scopescopescopescopeScope— the Construct scope.ididididId— the resource id.modelArnmodel_arnmodelArnmodelArnModelArn— the ARN of the model.
fromModelAttributes(scope: Construct, id: string, attrs: ModelAttributes): IModel@staticmethod def from_model_attributes(scope: Construct, id: str, attrs: ModelAttributes) -> IModelpublic static IModel fromModelAttributes(Construct scope, String id, ModelAttributes attrs)public static IModel FromModelAttributes(Construct scope, string id, ModelAttributes attrs)func FromModelAttributes(Scope Construct, Id *string, Attrs ModelAttributes) IModelstatic#3 parameters
Parameters
scopescopescopescopeScope— the Construct scope.ididididId— the resource id.attrsattrsattrsattrsAttrs— the attributes of the model to import.
fromModelName(scope: Construct, id: string, modelName: string): IModel@staticmethod def from_model_name(scope: Construct, id: str, model_name: str) -> IModelpublic static IModel fromModelName(Construct scope, String id, String modelName)public static IModel FromModelName(Construct scope, string id, string modelName)func FromModelName(Scope Construct, Id *string, ModelName *string) IModelstatic#3 parameters
Parameters
scopescopescopescopeScope— the Construct scope.ididididId— the resource id.modelNamemodel_namemodelNamemodelNameModelName— the name of the model.
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#notes · 1 parameter · returns
Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.
Parameters
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Construct.
isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.