DockerImage Class
Creates IDockerImage instances.
| Source | aws-stepfunctions-tasks/lib/sagemaker/base-types.ts |
|---|---|
| Type last changed |
Example
ts
new tasks.SageMakerCreateModel(this, 'Sagemaker', {
modelName: 'MyModel',
primaryContainer: new tasks.ContainerDefinition({
image: tasks.DockerImage.fromJsonExpression(sfn.JsonPath.stringAt('$.Model.imageName')),
mode: tasks.Mode.SINGLE_MODEL,
modelS3Location: tasks.S3Location.fromJsonExpression('$.TrainingJob.ModelArtifacts.S3ModelArtifacts'),
}),
});
python
tasks.SageMakerCreateModel(self, "Sagemaker",
model_name="MyModel",
primary_container=tasks.ContainerDefinition(
image=tasks.DockerImage.from_json_expression(sfn.JsonPath.string_at("$.Model.imageName")),
mode=tasks.Mode.SINGLE_MODEL,
model_s3_location=tasks.S3Location.from_json_expression("$.TrainingJob.ModelArtifacts.S3ModelArtifacts")
)
)
java
SageMakerCreateModel.Builder.create(this, "Sagemaker")
.modelName("MyModel")
.primaryContainer(ContainerDefinition.Builder.create()
.image(DockerImage.fromJsonExpression(JsonPath.stringAt("$.Model.imageName")))
.mode(Mode.SINGLE_MODEL)
.modelS3Location(S3Location.fromJsonExpression("$.TrainingJob.ModelArtifacts.S3ModelArtifacts"))
.build())
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
new SageMakerCreateModel(this, "Sagemaker", new SageMakerCreateModelProps {
ModelName = "MyModel",
PrimaryContainer = new ContainerDefinition(new ContainerDefinitionOptions {
Image = DockerImage.FromJsonExpression(JsonPath.StringAt("$.Model.imageName")),
Mode = Mode.SINGLE_MODEL,
ModelS3Location = S3Location.FromJsonExpression("$.TrainingJob.ModelArtifacts.S3ModelArtifacts")
})
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
tasks.NewSageMakerCreateModel(this, jsii.String("Sagemaker"), &SageMakerCreateModelProps{
ModelName: jsii.String("MyModel"),
PrimaryContainer: tasks.NewContainerDefinition(&ContainerDefinitionOptions{
Image: tasks.DockerImage_FromJsonExpression(sfn.JsonPath_StringAt(jsii.String("$.Model.imageName"))),
Mode: tasks.Mode_SINGLE_MODEL,
ModelS3Location: tasks.S3Location_FromJsonExpression(jsii.String("$.TrainingJob.ModelArtifacts.S3ModelArtifacts")),
}),
})
Initializer
ts
new DockerImage()
python
DockerImage()
java
new DockerImage()
csharp
new DockerImage()
go
NewDockerImage()
Methods
bind(task: ISageMakerTask): DockerImageConfigdef bind(self, task: ISageMakerTask) -> DockerImageConfigpublic DockerImageConfig bind(ISageMakerTask task)public DockerImageConfig Bind(ISageMakerTask task)func Bind(Task ISageMakerTask) DockerImageConfig #Called when the image is used by a SageMaker task.
fromAsset(scope: Construct, id: string, props: DockerImageAssetProps): DockerImage // chainable@staticmethod def from_asset(scope: Construct, id: str, props: DockerImageAssetProps) -> DockerImagepublic static DockerImage fromAsset(Construct scope, String id, DockerImageAssetProps props)public static DockerImage FromAsset(Construct scope, string id, DockerImageAssetProps props)func FromAsset(Scope Construct, Id *string, Props DockerImageAssetProps) DockerImage static #Reference a Docker image that is provided as an Asset in the current app.
3 parameters
Parameters
scopescopescopescopeScope— the scope in which to create the Asset.ididididId— the ID for the asset in the construct tree.propspropspropspropsProps— the configuration props of the asset.
fromEcrRepository(repository: IRepository, tagOrDigest?: string): DockerImage // chainable@staticmethod def from_ecr_repository(repository: IRepository, tag_or_digest: typing.Optional[str] = None) -> DockerImagepublic static DockerImage fromEcrRepository(IRepository repository, String tagOrDigest)public static DockerImage FromEcrRepository(IRepository repository, string? tagOrDigest = null)func FromEcrRepository(Repository IRepository, TagOrDigest *string) DockerImage static #Reference a Docker image stored in an ECR repository.
2 parameters
Parameters
repositoryrepositoryrepositoryrepositoryRepository— the ECR repository where the image is hosted.tagOrDigesttag_or_digesttagOrDigesttagOrDigestTagOrDigest— an optional tag or digest (digests must start withsha256:).
fromJsonExpression(expression: string, allowAnyEcrImagePull?: boolean): DockerImage // chainable@staticmethod def from_json_expression(expression: str, allow_any_ecr_image_pull: typing.Optional[bool] = None) -> DockerImagepublic static DockerImage fromJsonExpression(String expression, Boolean allowAnyEcrImagePull)public static DockerImage FromJsonExpression(string expression, bool? allowAnyEcrImagePull = null)func FromJsonExpression(Expression *string, AllowAnyEcrImagePull *bool) DockerImage static #Reference a Docker image which URI is obtained from the task's input.
2 parameters
Parameters
expressionexpressionexpressionexpressionExpression— the JSONata or JSON path expression with the task input.allowAnyEcrImagePullallow_any_ecr_image_pullallowAnyEcrImagePullallowAnyEcrImagePullAllowAnyEcrImagePull— whether ECR access should be permitted (set tofalseif the image will never be in ECR).
fromRegistry(imageUri: string): DockerImage // chainable@staticmethod def from_registry(image_uri: str) -> DockerImagepublic static DockerImage fromRegistry(String imageUri)public static DockerImage FromRegistry(string imageUri)func FromRegistry(ImageUri *string) DockerImage static #Reference a Docker image by it's URI.
When referencing ECR images, prefer using inEcr.
1 parameter
Parameters
imageUriimage_uriimageUriimageUriImageUri— the URI to the docker image.