Abhay Kumar
Abhay Kumar

Reputation: 141

│ Error: creating SageMaker model: ValidationException: Using non-ECR image "sagemaker-scikit-learn" without Vpc repository access mode not supported

I am trying to create two Sagemaker endpoints using Terraform. I am very new to terraform and can't find a similar issue on the internet. I must be making some silly mistake. Can anyone help me out with this error?

Getting below error : aws_sagemaker_model.sagemaker_prediction_electronics[0]: Still creating... [1m50s elapsed] │ Error: creating SageMaker model: ValidationException: Using non-ECR image "sagemaker-scikit-learn" without Vpc repository access mode is not supported. │ status code: 400, request id: e634bbdf-8bc5-4d62-b875-1663324a3283

Here is the section of the code where I am getting error.

resource "aws_sagemaker_model" "sagemaker_prediction" {
  count               = var.enable_departments_endpoint == true ? 1 : 0
  name               = "${var.environment}-departments-v2"
  execution_role_arn = aws_iam_role.sagemaker_prediction.arn

  primary_container {
    image          = data.aws_sagemaker_prebuilt_ecr_image.prediction.repository_name
    model_data_url = var.departments_model_s3_artefact
    environment    = var.sagemaker_vars
  }

  tags = local.common_tags

}

resource "aws_sagemaker_model" "sagemaker_prediction_electronics"{

  count              = var.enable_electronics_endpoint == true ? 1 : 0
  name               = "${var.environment}-electronics-v2-serverless"
  execution_role_arn = aws_iam_role.sagemaker_prediction.arn

  primary_container {
    image          = data.aws_sagemaker_prebuilt_ecr_image.cat_prediction.repository_name
    model_data_url = var.electronics_model_s3_artefact
  }
  tags = local.common_tags

}

Sharing image repository code as well below.

data "aws_sagemaker_prebuilt_ecr_image" "prediction" {
  repository_name = "sagemaker-scikit-learn"
  image_tag       = "0.23-1-cpu-py3"
}

data "aws_sagemaker_prebuilt_ecr_image" "cat_prediction" {
   repository_name = "tensorflow-inference"
   image_tag = "1"
}

Thanks in advance.

Upvotes: 3

Views: 410

Answers (0)

Related Questions