{"id":29705827,"url":"https://github.com/mathworks-ref-arch/matlab-on-gcp","last_synced_at":"2026-03-02T06:31:10.700Z","repository":{"id":293387566,"uuid":"900624591","full_name":"mathworks-ref-arch/matlab-on-gcp","owner":"mathworks-ref-arch","description":"MATLAB on GCP","archived":false,"fork":false,"pushed_at":"2025-09-18T13:55:00.000Z","size":1740,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-09-18T16:03:20.259Z","etag":null,"topics":["matlab-gcp"],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mathworks-ref-arch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-12-09T06:59:20.000Z","updated_at":"2025-09-18T13:55:04.000Z","dependencies_parsed_at":"2025-05-15T05:31:15.085Z","dependency_job_id":null,"html_url":"https://github.com/mathworks-ref-arch/matlab-on-gcp","commit_stats":null,"previous_names":["mathworks-ref-arch/matlab-on-gcp"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mathworks-ref-arch/matlab-on-gcp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks-ref-arch%2Fmatlab-on-gcp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks-ref-arch%2Fmatlab-on-gcp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks-ref-arch%2Fmatlab-on-gcp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks-ref-arch%2Fmatlab-on-gcp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mathworks-ref-arch","download_url":"https://codeload.github.com/mathworks-ref-arch/matlab-on-gcp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks-ref-arch%2Fmatlab-on-gcp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29994122,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-02T01:47:34.672Z","status":"online","status_checked_at":"2026-03-02T02:00:07.342Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["matlab-gcp"],"created_at":"2025-07-23T15:09:19.080Z","updated_at":"2026-03-02T06:31:10.609Z","avatar_url":"https://github.com/mathworks-ref-arch.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **MATLAB on Google Cloud Platform**\n\nThis repository shows how to build a Google® machine image for Linux® with MATLAB® and MATLAB toolboxes installed.\n\nA HashiCorp® Packer template generates the machine image. The template is an HCL2 file that tells Packer which plugins (builders, provisioners, post-processors) to use, how to configure those plugins, and what order to run them in. For more information, see [Packer Templates](https://www.packer.io/docs/templates#packer-templates).\n\n## Table of Contents\n1. [Requirements](#requirements)\n2. [Costs](#costs)\n3. [Quick Build Instructions](#quick-build-instructions)\n4. [Customize and Run Packer Build](#customize-and-run-packer-build)\n    1. [Build Time Variables](#build-time-variables)\n    2. [Customize Packer Build](#customize-packer-build)\n    3. [Installation Scripts](#installation-scripts)\n5. [Validate Packer Template](#validate-packer-template)\n6. [Deploy Machine Image](#deploy-machine-image)\n6. [Connect to Virtual Machine](#connect-to-virtual-machine)\n7. [Help Make MATLAB Even Better](#help-make-matlab-even-better)\n6. [Technical Support](#technical-support)\n\n\n## **Requirements**\n\n* A MATLAB license. For details, see [License Requirements for MATLAB on Cloud Platforms](https://www.mathworks.com/help/install/license/licensing-for-mathworks-products-running-on-the-cloud.html).\n* [Google Cloud CLI](https://cloud.google.com/sdk/docs/install). To log in, use: `gcloud auth application-default login`\n* [Google Cloud CLI](https://cloud.google.com/sdk/docs/install). To log in, use: `gcloud auth application-default login`\n* [Google Cloud \"Project ID\"](https://cloud.google.com/resource-manager/docs/creating-managing-projects#before_you_begin). To retrieve your Project ID, use: `gcloud config get-value project`\n* [Packer 1.7.0. or later](https://www.packer.io/downloads).\n* [Terraform 1.6.6 or later](https://developer.hashicorp.com/terraform/tutorials/gcp-get-started/install-cli).\n\n## **Costs**\nYou are responsible for the cost of the GCP services used when you create cloud resources using this guide. Resource settings, such as virtual machine type, affect the cost of deployment. For cost estimates, see the pricing pages for each GCP service you will be using. Prices are subject to change.\n\n## **Quick Build Instructions**\nThis section shows how to build the latest MATLAB machine image in your own GCP account. \n\nPull the source code and navigate to the Packer folder:\n```bash\ngit clone https://github.com/mathworks-ref-arch/matlab-on-gcp.git\ncd matlab-on-gcp/packer/v1\n```\n\nAssign the correct values to the `PROJECT_ID` and `OWNER` variables in the file `variables.auto.pkrvars.hcl`.\n\nInitialize Packer to install the required plugins.\nYou only need to do this once.\nFor more information, see [init command reference (Packer)](https://developer.hashicorp.com/packer/docs/commands/init).\n```bash\npacker init .\n## OR\npacker init build-gcp-matlab.pkr.hcl\n```\n\nStart the Packer build with the default settings:\n```bash\npacker build .\n## OR you could also directly pass the values from cli\npacker build -var=\"PROJECT_ID=unset\" -var=\"OWNER=unset\" build-gcp-matlab.pkr.hcl\n```\nPacker writes the output, including the ID of the generated machine image, to a `manifest.json` file when the build ends.\nTo use the built image with a MathWorks Terraform template, see [Deploy Machine Image](#deploy-machine-image).\n\nTo build a previous version of MATLAB, see [Customize MATLAB Release to Install](#customize-matlab-release-to-install)\n\n\n## **Customize and Run Packer Build**\nThis section describes the complete Packer build process and the different options for starting the build.\n\n\n### **Build-Time Variables**\nThe [Packer template](https://github.com/mathworks-ref-arch/matlab-on-gcp/tree/master/packer/v1/build-gcp-matlab.pkr.hcl)\nsupports these build-time variables:\n| Variable Name | Default Value | Description |\n|---|---|---|\n| [`PRODUCTS`](#customize-products-to-install)| MATLAB and all available toolboxes | Products to install, specified as a list of product names separated by spaces. For example, `MATLAB Simulink Deep_Learning_Toolbox Parallel_Computing_Toolbox`.\u003cbr/\u003eIf no products are specified, the Packer build will install MATLAB with all available toolboxes. For more information, see [MATLAB Package Manager](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/MPM.md).|\n| `BASE_IMAGE_FAMILY` |  ubuntu-2204-lts | The base image OS family. |\n| `VM_LABELS` |{name=\"packer-builder\", build=\"matlab-linux\"} | Tags to add to the Packer build instance.|\n| `IMAGE_LABELS` | {name=\"packer-build\", build=\"matlab\", type=\"matlab-on-gcp\"} | Tags to add to the machine image.|\n\nFor a full list of the variables used in the build, see the description fields in the\n[Packer template](https://github.com/mathworks-ref-arch/matlab-on-gcp/tree/master/packer/v1/build-gcp-matlab.pkr.hcl).\n\n\n\n### **Customize Packer Build**\n#### **Customize Products to Install**\nUse the Packer build-time variable `PRODUCTS` to specify the list of products you want to install on the machine image. If `PRODUCTS` is unspecified, Packer will install MATLAB with all the available toolboxes.\n\nFor example, to install the latest version of MATLAB and Deep Learning Toolbox, run:\n```bash\npacker build -var \"PRODUCTS=MATLAB Deep_Learning_Toolbox\" build-gcp-matlab.pkr.hcl\n```\n\n#### **Customize MATLAB Release to Install**\nTo use an earlier MATLAB release, use one of the variable definition files in the [release-config](https://github.com/mathworks-ref-arch/matlab-on-gcp/tree/master/packer/v1/release-config) folder.\nThese are available for MATLAB R2023a and later.\n\nFor example, to install MATLAB R2023b and all available toolboxes, run:\n```bash\npacker build -var-file=\"variables.auto.pkrvars.hcl\" -var-file=\"release-config/R2023b.pkrvars.hcl\" build-gcp-matlab.pkr.hcl\n```\nYou can also combine command line variables. For example, to install MATLAB R2023b and only the Parallel Computing Toolbox, run:\n```bash\npacker build -var-file=\"variables.auto.pkrvars.hcl\" -var-file=\"release-config/R2023b.pkrvars.hcl\" -var=\"PRODUCTS=MATLAB Parallel_Computing_Toolbox\" build-gcp-matlab.pkr.hcl\n```\nLaunch the customized image using the corresponding Terraform Template.\nFor instructions using Terraform Templates, see the Deployment Steps\nsection in [MATLAB on Google Cloud Platform](https://github.com/mathworks-ref-arch/matlab-on-gcp).\n#### **Customize Multiple Variables**\nYou can override default variable values in a separate [Variable Definition File](https://developer.hashicorp.com/packer/docs/templates/hcl_templates/variables#standard-variable-definitions-files).\n\nFor example, to generate a machine image with the latest MATLAB, the Deep Learning and Parallel Computing toolboxes, and a different machine type, create a variable definition file named `custom-variables.pkrvars.hcl` containing these variable definitions.\n```\nMACHINE_TYPE    = \"e2-highcpu-8\"\nPRODUCTS        = \"MATLAB Deep_Learning_Toolbox Parallel_Computing_Toolbox\"\n```\n\nTo specify a MATLAB release using a variable definition file, modify the variable definition file\nin the [release-config](https://github.com/mathworks-ref-arch/matlab-on-gcp/tree/master/packer/v1/release-config)\nfolder corresponding to the desired release.\n\nSave the variable definition file and include it in the Packer build command.\n```bash\npacker build -var-file=\"custom-variables.pkrvars.hcl\" build-gcp-matlab.pkr.hcl\n```\n\n### **Installation Scripts**\nThe Packer build executes scripts on the image builder instance during the build.\nThese scripts perform tasks such as\ninstalling tools needed by the build,\ninstalling MATLAB and toolboxes on the image using [MATLAB Package Manager](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/MPM.md),\nand cleaning up build leftovers (including bash history).\n\nFor the full list of scripts that the Packer build executes during the build, see the `BUILD_SCRIPTS` parameter in the\n[Packer template](https://github.com/mathworks-ref-arch/matlab-on-gcp/tree/master/packer/v1/build-gcp-matlab.pkr.hcl).\n\nIn addition to the build scripts above, the Packer build copies further scripts to the machine image,\nto be used during startup and at runtime. These scripts perform tasks such as setting up RDP, warming up MATLAB, and other utility tasks.\n\nFor the full list of startup scripts, see the `STARTUP_SCRIPTS` parameters in the\n[Packer template](https://github.com/mathworks-ref-arch/matlab-on-gcp/tree/master/packer/v1/build-gcp-matlab.pkr.hcl).\n\n\n## **Deploy Machine Image**\nWhen the build finishes, Packer writes\nthe output to a `manifest.json` file, which contains these fields:\n```json\n{\n  \"builds\": [\n    {\n      \"name\":,\n      \"builder_type\": ,\n      \"build_time\": ,\n      \"files\": ,\n      \"artifact_id\": ,\n      \"packer_run_uuid\": ,\n      \"custom_data\": {\n        \"build_scripts\": ,\n        \"release\": ,\n        \"specified_products\":\n      }\n    }\n  ],\n  \"last_run_uuid\": \"\"\n}\n```\n\nThe `artifact_id` section shows the ID of the machine image generated by the most recent Packer build. Update the `image_name` in `terraform/terraform.tfvars` with the `artifact_id`.\n\nFollowing the successful build, the new GCP image can be found in the console output or by using the following URL. Replace the value for `project_id` in `terraform/terraform.tfvars`.\n\n    https://console.cloud.google.com/compute/images?tab=images\u0026project=\u003cPROJECT_ID\u003e\n\nThe Terraform templates provided by MathWorks require you to run a [Packer build](#build-a-vhd) beforehand. \n\nEither use the [GCP Cloud shell](https://cloud.google.com/shell/docs/using-cloud-shell) or install Terraform locally. If you are using GCP with Terraform for the first time, you might have to set your project in your environment. You can do this by running: \n```bash\ngcloud config set project \u003cPROJECT_ID\u003e\n```\n\nOnce you have completed the setup, you can run the following commands to add the necessary plugins  to the `.terraform` directory, and get a preview of the resources to be created: \n```bash\ncd ../../terraform\nterraform init\nterraform plan\n```\n\nTo spawn the resources, execute:\n```bash\nterraform apply\n## OR you could also directly pass the values from cli\nterraform apply -var image_name=\"matlab-linux-r2024b-xxxx\" -var project_id=\"unset\" -var 'labels={owner=\"unset\", environment=\"dev\"}'\n```\n\nOptionally, you can also override the default variables, either in `/terraform/terraform.tfvars`, or by directly providing the values inline. For example, to create a static IP address and use an existing VPC and subnet:\n\n```bash\nterraform plan \\\n    -var create_static_ip=true \\\n    -var existing_vpc_name=\"\u003cexisting-vpc\u003e\" \\\n    -var existing_subnet_name=\"\u003cexisting-subnet\u003e\"\n\nterraform apply \\\n    -var create_static_ip=true \\\n    -var existing_vpc_name=\"\u003cexisting-vpc\u003e\" \\\n    -var existing_subnet_name=\"\u003cexisting-subnet\u003e\"\n```\n\nTo delete the spawned resources, execute: \n```bash\nterraform destroy\n```\n\nIf you have customized the build, for example by removing or modifying one or more of the included scripts, the resulting machine image **might no longer be compatible** with the provided Terraform template.\nIn some cases you can restore compatibility by making corresponding modifications to the Terraform template.\n\n### **Run-Time Variables**\nYou can configure the following variables in `/terraform/terraform.tfvars` before deployment.\n\n| Variable Name | Default Value | Description |\n|---|---|---|\n| `labels.owner` * | _unset_ | Update the name of the owner to tag it to the image. |\n| `project_id` * | _unset_ | Update the Google Cloud Project ID - A globally unique identifier for your project. |\n| `image_name` * | _unset_ | Update the machine image name after the Packer build. This can be found in `manifest.json` having label `artifact_id` |\n| `tag` | \"matlab\" | Use a unique prefix tag to distinguish multiple VMs. |\n| `existing_vpc_name` | _unset_ | Existing VPC name. If empty, a new VPC will be created. |\n| `existing_subnet_name` | _unset_ | Existing subnet name. If empty, a new subnet will be created. |\n| `allow_client_ip` * | [] | Update with the specific client machine public IP address. E.g. [\\\"11.22.33.44/32\\\",\\\"44.55.66.77/32\\\"] |\n| `create_static_ip` | false | Choose whether to have a static IP address across machine restarts. |\n| `license_manager` | _unset_ | Optional License Manager for MATLAB, specified as `\u003cport\u003e@\u003chostname\u003e`. If not specified, use online licensing. |\n| `optional_user_command` | _unset_ | Provide an optional inline shell command to run on machine launch. |\n\nFor a full list of the variables used in the deployment, see the description fields in the [Terraform variables](https://github.com/mathworks-ref-arch/matlab-on-gcp/tree/master/terraform/terraform.tfvars) file.\n\nVariables having * means they are mandatory.\n\n## **Connect to Virtual Machine**\nYou can connect to the VM with either ssh or RDP. Refer the below table on how to use each protocol.\n\n| Connection Protocol | Steps to use |\n|---|---|\n| ssh | - Look for the value of `ssh_command` in the output post your deployment. \u003cbr\u003e - Connect using the gcloud ssh. Sample command `gcloud compute ssh instance-name --zone=us-west1-a` \u003cbr\u003e - Optionally you could also create a new user by using format `gcloud compute ssh user@instance-name --zone=us-west1-a`. \u003cbr\u003e - See [here](https://cloud.google.com/sdk/gcloud/reference/compute/ssh) for more information.   |\n| RDP | - Follow the ssh steps and you must set the password for the user by running `sudo passwd \u003cuser-name\u003e`. \u003cbr\u003e - Use the user and password to login into the RDP. |\n\n## **Tips and Troubleshooting**\n\n- **Use remote backend to store state files:** It is recommended to use the remote backends to store the Terraform state file. Terraform provides backend configuration. See the commented lines in `main.tf` or [here](https://developer.hashicorp.com/terraform/language/settings/backends/gcs) for more information.\n\n- **Install Support Packages:** To install specific support package(s), use Add-Ons manager. See [here](https://in.mathworks.com/help/matlab/matlab_env/get-add-ons.html).\n\n- **Dry run Terraform:** Always use `terraform plan` to review changes before applying them. This helps in understanding the impact of the changes and prevents unintended actions.\n\n- **Validate Packer Template:** To validate the syntax and configuration of a Packer template, use the `packer validate` command. This command also checks whether the provided input variables meet the custom validation rules defined by MathWorks. For more information, see [`validate` Command](https://www.packer.io/docs/commands/validate#validate-command).\nYou can also use command line interfaces provided by Packer to inspect and format the template. For more information, see [Packer Commands (CLI)](https://www.packer.io/docs/commands).\n\n- **Debug Packer:** Utilize Packer's debug mode `packer build -debug` for a more interactive build process. This is especially useful for troubleshooting and understanding the build process.\n\n\n## **Help Make MATLAB Even Better**\nYou can help improve MATLAB by providing user experience information on how you use MathWorks products. Your participation ensures that you are represented and helps us design better products.\nTo opt out of this service, remove the [mw_context_tag.sh](https://github.com/mathworks-ref-arch/matlab-on-gcp/tree/master/packer/v1/build/config/matlab/mw_context_tag.sh)\nscript under the `config` folder,\nand the line in [install-matlab.sh](https://github.com/mathworks-ref-arch/matlab-on-gcp/tree/master/packer/v1/build/install-matlab.sh)\nwhich moves `mw_context_tag.sh` to the image.\n\nTo learn more, see the documentation: [Help Make MATLAB Even Better - Frequently Asked Questions](https://www.mathworks.com/support/faq/user_experience_information_faq.html).\n\n## **Technical Support**\nTo request assistance, or additional features, contact [MathWorks Technical Support](https://www.mathworks.com/support/contact_us.html).\n\n\n----\n\nCopyright 2024-2025 The MathWorks, Inc.\n\n----\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathworks-ref-arch%2Fmatlab-on-gcp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmathworks-ref-arch%2Fmatlab-on-gcp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathworks-ref-arch%2Fmatlab-on-gcp/lists"}