AWS Sagemaker Model Deployment Steps
To Build and Deploy the Model End Point in AWS Sagemaker using aws cli commands , Following are the steps
Create a Model – Creates a model in Amazon SageMaker. Below is the syntax
aws sagemaker create-model \
--model-name <model name> \
--primary-container \
Image=<Repository URL>:<Image Tag>,ModelDataUrl=s3://<bucket name>/models/<job name>/output/model.tar.gz \
--execution-role-arn <Role ARN> \
--vpc-config <config details> \
--tags <tag details>
Sample Below
aws sagemaker create-model --model-name 'sagemaker-aws-cli-model' --primary-container Image='111111111111.dkr.ecr.us-east-1.amazonaws.com/sagemakertestmodel',ModelDataUrl='s3://sagemaker-test-bucket/model.tar.gz' --execution-role-arn 'arn:aws:iam::111111111111:role/sagemaker-test-role' --vpc-config SecurityGroupIds='sg-aaaaaaa',Subnets='subnet-ddddddd','subnet-eeeeeee' --tags Key='tag1',Value='test'
Create Endpoint Configuration – Creates an endpoint configuration that Amazon SageMaker hosting services uses to deploy models. Below is the syntax
aws sagemaker create-endpoint-config \
--endpoint-config-name <endpoint config name> \
--production-variants \
VariantName=AllTraffic,ModelName=<model name>,InitialInstanceCount=1,InstanceType=ml.m4.xlarge,InitialVariantWeight=1.0 \
--data-capture-config \
EnableCapture=boolean,InitialSamplingPercentage=integer,DestinationS3Uri=string,KmsKeyId=string,CaptureOptions=[{CaptureMode=string},{CaptureMode=string}] \
----kms-key-id <kmskey> \
----tags <tag details>
Sample Below
aws sagemaker create-endpoint-config --endpoint-config-name 'sagemaker-aws-cli-endpoint-config' --production-variants VariantName=AllTraffic,ModelName='sagemaker-aws-cli-model',InitialInstanceCount=1,InstanceType=ml.m5.4xlarge,InitialVariantWeight=1.0 --data-capture-config EnableCapture=true,InitialSamplingPercentage=100,DestinationS3Uri='s3://sagemaker-test-bucket/modeldatacapture/',KmsKeyId='arn:aws:kms:us-east-1:111111111111:key/aaaaaaa-2222-eeee-xxxx-ccccccccc',CaptureOptions=[{CaptureMode=Input},{CaptureMode=Output}] --kms-key-id 'arn:aws:kms:us-east-1:111111111111:key/aaaaaaa-2222-eeee-xxxx-ccccccccc' --tags Key='tag1',Value='test'
Create Endpoint – Creates an endpoint using the endpoint configuration specified in the request. Below is the syntax
aws sagemaker create-endpoint \
--endpoint-name <endpoint name> \
--endpoint-config-name <endpoint config name>
--tags <tag details>
Sample Below
aws sagemaker create-endpoint --endpoint-name 'sagemaker-aws-cli-endpoint' --endpoint-config-name 'sagemaker-aws-cli-endpoint-config' --tags Key='tag1',Value='test'