Skip to content

Instantly share code, notes, and snippets.

@dpwrussell
Last active March 3, 2020 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dpwrussell/5c34a7c98cb1a4d07d9718f6e7cf7c69 to your computer and use it in GitHub Desktop.
Save dpwrussell/5c34a7c98cb1a4d07d9718f6e7cf7c69 to your computer and use it in GitHub Desktop.
MATLAB Reference Architecture CLI Example Usage

CLI Examples for MathWorks' Reference Architectures

These are examples of creating and deleting reference architectures for three MathWorks offerings; MATLAB, MATLAB Parallel Server and Network License Manager for MATLAB. There are examples for both AWS and Azure.

In each of the examples, the minimum parameters are supplied. The values for each parameter are specific to your AWS account and the deployment you with to create, so they should be set by the user. The documentation (linked to from each of the examples) goes into details of all possible parameters and their purpose.

AWS

From R2019b and after, each template supports multiple regions. So this can be used in any region that we support.

These examples use the AWS CLI and are written in bash.

MATLAB

For MATLAB on Amazon Web Services reference architecture.

AWS_REGION="us-east-1"
TEMPLATE_URL="https://s3.amazonaws.com/matlab-on-aws/aws-matlab-2019b-template.json"
STACK_NAME="stackname"
SSH_KEY="key-pair-name"
VPC="vpc-00000000"
SUBNET="subnet-00000000"
CLIENT_CIDR="0.0.0.0/32"
USERNAME="username"
PASSWORD="password"

# Create stack
aws cloudformation create-stack \
    --region ${AWS_REGION} \
    --stack-name ${STACK_NAME} \
    --template-url ${TEMPLATE_URL} \
    --capabilities CAPABILITY_IAM \
    --parameters \
        ParameterKey=SSHKeyName,ParameterValue=${SSH_KEY} \
        ParameterKey=VPC,ParameterValue=${VPC} \
        ParameterKey=SubnetA,ParameterValue=${SUBNET} \
        ParameterKey=ClientIPAddress,ParameterValue=${CLIENT_CIDR} \
        ParameterKey=Username,ParameterValue=${USERNAME} \
        ParameterKey=Password,ParameterValue=${PASSWORD} \
        ParameterKey=ConfirmPassword,ParameterValue=${PASSWORD}

# Delete stack
aws cloudformation delete-stack \
    --stack-name ${STACK_NAME}

MATLAB Parallel Server

For MATLAB Parallel Server on Amazon Web Services reference architecture.

AWS_REGION="us-east-1"
TEMPLATE_URL="https://mdcs-on-aws.s3.amazonaws.com/R2019b/mjs-cluster-template.json"
STACK_NAME="stackname"
SSH_KEY="key-pair-name"
VPC="vpc-00000000"
SUBNETS="\"subnet-00000000,subnet-11111111,subnet-22222222,subnet-33333333,subnet-44444444,subnet-55555555\""
CLIENT_CIDR="0.0.0.0/32"
WORKER_INSTANCE_TYPE="g3s.xlarge"
CLUSTER_NAME="clustername"

# Create stack
aws cloudformation create-stack \
    --region ${AWS_REGION} \
    --stack-name ${STACK_NAME} \
    --template-url ${TEMPLATE_URL} \
    --capabilities CAPABILITY_IAM \
    --parameters \
        ParameterKey=SSHKeyName,ParameterValue=${SSH_KEY} \
        ParameterKey=VPC,ParameterValue=${VPC} \
        ParameterKey=Subnets,ParameterValue=${SUBNETS} \
        ParameterKey=ClientIPAddress,ParameterValue=${CLIENT_CIDR} \
        ParameterKey=WorkerInstanceType,ParameterValue=${WORKER_INSTANCE_TYPE} \
        ParameterKey=ClusterName,ParameterValue=${CLUSTER_NAME}

# Delete stack
aws cloudformation delete-stack \
    --stack-name ${STACK_NAME}

Network License Manager for MATLAB

For Network License Manager for MATLAB on Amazon Web Services reference architecture.

AWS_REGION="us-east-1"
TEMPLATE_URL="https://network-license-manager-for-matlab-on-aws.s3.amazonaws.com/R2019b/license-manager-template.json"
STACK_NAME="stackname"
SSH_KEY="key-pair-name"
VPC="vpc-00000000"
SUBNET="subnet-00000000"
CLIENT_CIDR="0.0.0.0/32"
PASSWORD="password"

# Create stack
aws cloudformation create-stack \
    --region ${AWS_REGION} \
    --stack-name ${STACK_NAME} \
    --template-url ${TEMPLATE_URL} \
    --parameters \
        ParameterKey=SSHKeyName,ParameterValue=${SSH_KEY} \
        ParameterKey=VPC,ParameterValue=${VPC} \
        ParameterKey=Subnet,ParameterValue=${SUBNET} \
        ParameterKey=ClientIPAddress,ParameterValue=${CLIENT_CIDR} \
        ParameterKey=Password,ParameterValue=${PASSWORD} \
        ParameterKey=ConfirmPassword,ParameterValue=${PASSWORD}

# Delete stack
aws cloudformation delete-stack \
    --stack-name ${STACK_NAME}

Azure

These examples use the Azure CLI and are written in PowerShell.

MATLAB

For MATLAB on Azure reference architecture.

$templateUri = 'https://raw.githubusercontent.com/mathworks-ref-arch/matlab-on-azure/master/releases/R2019b/azuredeploy-R2019b.json'
$userName = 'username'
$userPassword = 'ComplexPassword1@'
$clientCidr = '0.0.0.0/32'
$resourceGroupName = 'resourcegroup'
$location= 'East US'
$deploymentName = 'deploymentname'

# Create deployment
$secureAdminPassword=ConvertTo-SecureString "$userPassword" –asplaintext –force
New-AzResourceGroup -Name $resourceGroupName -Location $location
New-AzResourceGroupDeployment `
   -Name $deploymentName `
   -ResourceGroupName $resourceGroupName `
   -TemplateUri $templateUri `
   -clientIpAddress "$clientCidr" `
   -userName "$userName" `
   -userPassword $secureAdminPassword

# Delete deployment
Remove-AzResourceGroup -Name $resourceGroupName -Force

MATLAB Parallel Server

For MATLAB Parallel Server on Azure reference architecture.

$templateUri = 'https://raw.githubusercontent.com/mathworks-ref-arch/matlab-parallel-server-on-azure/master/releases/R2019b/azuredeploy-R2019b.json'
$clusterName = 'clustername'
$adminUsername = 'username'
$adminPassword = 'ComplexPassword1@'
$clientCidr = '0.0.0.0/32'
$resourceGroupName = 'resourcegroup'
$location= 'East US'
$workerInstanceType = 'Standard_D4s_v3'
$deploymentName = 'deploymentname'

# Create deployment
$secureAdminPassword=ConvertTo-SecureString "$adminPassword" –asplaintext –force
New-AzResourceGroup -Name $resourceGroupName -Location $location
New-AzResourceGroupDeployment `
   -Name $deploymentName `
   -ResourceGroupName $resourceGroupName `
   -TemplateUri $templateUri `
   -clientIpAddress "$clientCidr" `
   -adminUsername "$adminUsername" `
   -adminPassword $secureAdminPassword `
   -clusterName "$clusterName" `
   -workerInstanceType "$workerInstanceType"

# Delete deployment
Remove-AzResourceGroup -Name $resourceGroupName -Force

Network License Manager for MATLAB

For Network License Manager for MATLAB on Azure reference architecture.

$templateUri = 'https://raw.githubusercontent.com/mathworks-ref-arch/license-manager-for-matlab-on-azure/master/releases/R2019b/azuredeploy-R2019b.json'
$adminUsername = 'username'
$adminPassword = 'ComplexPassword1@'
$clientCidr = '0.0.0.0/32'
$resourceGroupName = 'resourcegroup'
$location= 'East US'
$instanceType = 'Standard_D2s_v3'
$deploymentName = 'deploymentname'

# Create Deployment
$secureAdminPassword=ConvertTo-SecureString "$adminPassword" –asplaintext –force
New-AzResourceGroup -Name $resourceGroupName -Location $location
New-AzResourceGroupDeployment `
   -Name $deploymentName `
   -ResourceGroupName $resourceGroupName `
   -TemplateUri $templateUri `
   -clientIpAddress "$clientCidr" `
   -adminUsername "$adminUsername" `
   -adminPassword $secureAdminPassword `
   -instanceType "$instanceType"

# Delete deployment
Remove-AzResourceGroup -Name $resourceGroupName -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment