SageMaker models should use private registry in VPC for primary containers
Checks that the model's primary container has repository access mode Vpc, pulling its image from a private Docker registry in your VPC; Platform (Amazon ECR) or no image configuration fails. The image then comes from a registry you control, over your VPC rather than the public internet, which limits the risk of a swapped or tampered image.
- service
- SageMaker
- severity
- Medium
- scope
- evaluated in every region
How to fix it
- Replaces the resource: A model cannot be edited: create a new one with these settings, point each endpoint (through a new endpoint configuration), batch transform job and pipeline step at it, then delete this one.
- Affects another check: A model that also has a container list fails SageMaker.19 too; set Vpc on every container in the same replacement to clear both.
Settings
- PrimaryContainer.
ImageConfig. RepositoryAccessMode - Vpc
- PrimaryContainer.
Image - The image in your private registry, which needs a TLS certificate from a public certificate authority
- VpcConfig
- Subnets in the registry's VPC, and security groups the registry accepts inbound traffic from
- PrimaryContainer.
ImageConfig. RepositoryAuthConfig - For a registry that needs credentials: RepositoryCredentialsProviderArn, a Lambda function that returns them
With the AWS CLI
aws sagemaker create-model --model-name <model-name> --execution-role-arn <execution-role-arn> --primary-container '{"Image":"<private-registry-image-uri>","ImageConfig":{"RepositoryAccessMode":"Vpc"}}' --vpc-config '{"SecurityGroupIds":["<security-group-id>"],"Subnets":["<subnet-id>"]}' --region <region>With Terraform
resource "aws_sagemaker_model" "this" {
name = var.model_name
execution_role_arn = var.execution_role_arn
primary_container {
image = var.private_registry_image_uri
image_config {
repository_access_mode = "Vpc"
}
}
vpc_config {
security_group_ids = var.security_group_ids
subnets = var.subnet_ids
}
}
See which of your accounts this check is failing on.
Book a live scan