The following guide will help you automate the process of running MATLAB Web App Server on the Google Cloud Platform™ (GCP). The automation is accomplished using Terraform™ scripts and is supported for Linux environments only.
- MathWorks:
- MATLAB Web App Server® release R2020a or later
- MATLAB® License Manager on Google Cloud Platform
- Google Cloud Platform:
- Access to Google Cloud™ service account credentials
- Access to Google Cloud™ project
- Enabled Google Cloud Platform APIs
- Install Google Cloud SDK to access gcloud™ and gsutil™ APIs.
- SSH keys for authenticating gcloud™ and gsutil™ communication.:
- Learn how to create SSH keys.
- Learn how to locate an existing SSH key.
- Terraform (v1.0) : Documentation for Installing Terraform
- Linux : Install the following Linux packages on your system/VM: unzip, wget, curl, jq.
The following steps can help in getting started:
- Clone this repository as follows:
>> git clone https://github.com/mathworks-ref-arch/matlab-web-app-server-on-gcp-using-terraform.git
-
Make sure you have an existing Network License Manager setup on Google Cloud as well. See instructions on setting up a Network License Manager on Google Cloud here.
-
Install Google Cloud SDK. This step will ensure you are able to run
gcloud
andgsutil
commands from the system provisioning Google Cloud resources. Perform gcloud authentication using commandgcloud auth login
. This will authorize the gcloud API to access the Cloud Platform with your Google user credentials. -
Install Terraform v1.0 on Linux.
-
Terraform configuration uses some startup scripts for initialization of VMs. To authenticate Terraform requires
metadata-based SSH key configurations
. Create a set of SSH keys if one does not exist. See this link for steps. Provide the location of this key withinvariables.tf
for both Build and Deploy stage as follows.
# Path to ssh key for gcloud login and authorization
variable "gce_ssh_key_file_path" {
type = string
description = "/home/local-gce-user/.ssh/google_compute_engine.pub"
default = "/home/matlabuser/.ssh/google_compute_engine.pub"
}
-
Configure the default values for variables within
Software/variables.tf
. For more details see Software/Readme.md. -
Run
terraform init
andterraform validate
to make sure your current configuration based on default values set invariables.tf
is intialized and valid. -
This repository includes an example script, which can used to standup a sample MATLAB Web App Server cluster on Google Cloud, provided all dependencies have been installed and authentication related steps have been followed. Note: The values used for the subset of variables initialized within the
example.sh
script will override the values for the variables set withinvariables.tf
.
In order to make requests against any required Google Cloud Platform API, the user needs to authenticate himself/herself. The preferred method of provisioning resources with Terraform is to use a Google Cloud service account, that can be granted a limited set of IAM permissions scoped out by the platform administrator.
In order to access a set of credentials, a user can visit the service account key page in the Cloud Console and choose an accessible Google cloud project to list the existing service accounts. One can either choose an existing service account, or create a new one based on permissions. See steps for creating a service account. Once a service account is ready for use, the user needs to download the JSON key file from the selected service account on the local machine/VM being used for provisioning. The next step is to define an environment variable GOOGLE_APPLICATION_CREDENTIALS
to provide application level access to the credentials. See instructions for setting the environment variable.
Also, provide the location of the credentials within variables.tf
as shown below.
# Path to service account credentials
variable "credentials_file_path"{
type = string
default = "credentials.json"
description = "Provide full path to the credentials file for your service account"
}
For more details, see Terraform documentation on support for adding credentials.
- Google Compute instance to host the web app server.
- VPC network (Optional):
- Firewall rules allowing INGRESS for MATLAB Web App Server ports over
http
,https
andssh
. - Target tags to apply Firewall rules for the selected Google Compute instance.
- Firewall rules allowing INGRESS for MATLAB Web App Server ports over
- Configure MATLAB Web App Server Licensing.
- Google Cloud authentication using Service Accounts
- About MATLAB Web App Server
- MATLAB Runtime Installers
The license for this reference architecture is available in the LICENSE.MD file in this repository. This package uses certain third-party content which is licensed under separate license agreements.
Provide suggestions for additional features or capabilities using the following link: https://www.mathworks.com/products/reference-architectures/request-new-reference-architectures.html
Email: [email protected]