Skip to content

Instantly share code, notes, and snippets.

@leehanchung
Created December 21, 2019 00:02
Show Gist options
  • Save leehanchung/254debc191fef90ec98f370ae7437ecc to your computer and use it in GitHub Desktop.
Save leehanchung/254debc191fef90ec98f370ae7437ecc to your computer and use it in GitHub Desktop.
Bash script for creating Sagemaker Model from AWS ECR Docker Image repository
#!/usr/bin/env bash
MODEL_NAME=<<name your model>>
ROLE_NAME=AmazonSageMaker-ExecutionRole-XXXXXXXXXXXXXXXX
# the name of the image created with
ECS_IMAGE_NAME=<<your image name>>
# the role arn of the role
EXECUTION_ROLE_ARN=$(aws iam get-role --role-name ${ROLE_NAME} | jq -r .Role.Arn)
# the ECS image URI
ECS_IMAGE_URI=$(aws ecr describe-repositories --repository-name ${ECS_IMAGE_NAME} | jq -r .repositories[0].repositoryUri)
# defines the SageMaker model primary container image as the ECS image
PRIMARY_CONTAINER="Image=${ECS_IMAGE_URI}"
# creates the model
aws sagemaker create-model --model-name ${MODEL_NAME} \
--primary-container=${PRIMARY_CONTAINER} --execution-role-arn ${EXECUTION_ROLE_ARN}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment