Skip to main content

Machine Learning Model Release Definition Templates

hashicorp-aws offers a Screwdriver template that deploys immutable instances of Machine Learning models as REST API to AWS. It uses the screwdriver-template-main npm package to assist with template validation, publishing, and tagging.

This release definition contains the following templates:

All templates tag the latest versions with the latest tag.

How to Use the Templates

Using the Template

Create a Screwdriver pipeline that uses this template with the following contents:

---
jobs:
main:
requires: [~pr, ~commit]
template: QubitPi/machine-learning-model-release-definition-template-mlflow-docker@latest
steps:
- build-ml-models: ...
secrets:
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
- AWS_ML_PKRVARS_HCL
- AWS_ML_TFVARS

The following Screwdriver CD - steps must be implemented:

The following Screwdriver Secrets needs to be defined before running this template:

  • AWS_ACCESS_KEY_ID

  • AWS_SECRET_ACCESS_KEY

  • AWS_ML_PKRVARS_HCL - A HashiCorp Packer variable values file with the following variable values:

    aws_image_region = "us-east-2"
    ami_name = "my-ml-ami"
    instance_type = "t2.small"
    ml_models_path = "/home/my-nlp-models"
    • aws_image_region is the image region of AWS AMI
    • ami_name is the name of the resulting AMI that will appear when managing AMIs in the AWS console or via APIs. This can be the same across builds, because hashicorp-aws will deregister the old AMI with the same name and replace it with the current built one
    • instance_type is the recommended AWS EC2 instance type running this image
    • ml_models_path is the absolute path to the model directory generated by the build-ml-models step above
  • AWS_ML_TFVARS - A HashiCorp Terraform variable values file with the following variable values:

    aws_ec2_region   = "us-east-2"
    ami_name = "my-ml-ami"
    instance_type = "t2.small"
    ec2_instance_name = "My Machine Learning REST Service"
    ec2_security_groups = ["ML REST Service Security Group"]
    • aws_ec2_region is the EC2 runtime region
    • ami_name is the name of the published AMI; it must be the same as the ami_name in AWS_ML_PKRVARS_HCL
    • instance_type is the AWS EC2 instance type used for deployed infrastructure
    • ec2_instance_name is the deployed EC2 name as appeared in the instance list of AWS console; it can be arbitrary
    • ec2_security_groups is the AWS Security Group name (yes, not ID, but name...)