主要内容

Run MATLAB on AWS GovCloud (US) or AWS China

You can run MATLAB® or MATLAB Parallel Server™ on AWS® GovCloud (US) or Amazon® Web Services China by building your own machine image using MathWorks® provided HashiCorp Packer templates and then deploying this machine image.

These steps provide you with a quick guide on how to build your own reference architecture on AWS GovCloud (US) or AWS China. For detailed instructions on customizing and deploying your own Amazon machine image (AMI), see the Build Your Own Machine Image instructions in the corresponding GitHub® repository listed below.

Requirements

To use this offering, you need:

  • A valid Packer installation later than 1.7.0. For more information, see Install Packer.

  • AWS GovCloud (US) or AWS China credentials with sufficient permission. For more information, see Packer Authentication.

Create Amazon Machine Image

  1. From your system terminal, pull the source code from the respective GitHub repository.

    ProductGitHub RepositoryClone Repository
    MATLAB on Linux®https://github.com/mathworks-ref-arch/matlab-on-aws
    git clone https://github.com/mathworks-ref-arch/matlab-on-aws.git
    
    MATLAB on Windows®https://github.com/mathworks-ref-arch/matlab-on-aws-win
    git clone https://github.com/mathworks-ref-arch/matlab-on-aws-win.git
    
    MATLAB Parallel Server on Linuxhttps://github.com/mathworks-ref-arch/matlab-parallel-server-on-aws
    git clone https://github.com/mathworks-ref-arch/matlab-parallel-server-on-aws.git
    
    MATLAB Parallel Server on Windowshttps://github.com/mathworks-ref-arch/matlab-parallel-server-on-aws-win
    git clone https://github.com/mathworks-ref-arch/matlab-parallel-server-on-aws-win.git
    

  2. Navigate to the /packer/v1/ folder.

  3. Initialize Packer to install the required plugins. You only need to do this once. For more information, see init command reference (Packer).

    packer init .

  4. Make changes to the Packer HCL2 file in the /packer/v1/ folder.

    ParameterDescription of ParameterPacker Template Value for AWS GovCloud (US)Packer Template Value for AWS China
    regionAWS Region in which to build the AMI.For example, us-gov-west-1.For example, cn-north-1 or cn-northwest-1.
    owners field in the source_ami_filterOwnerID of the owner of the base image used in the build.

    For the Linux base image, you can find this value on the Canonical documentation page: https://documentation.ubuntu.com/aws/aws-how-to/instances/find-ubuntu-images/.

    For the Windows base image, ensure to insert the appropriate value corresponding to the base image you have chosen.

    default field in BASE_AMI_NAME variableName of the base AMI image for the latest MATLAB release. If you are using a previous release, ensure to also change this value in the HCL file in the specific release folder under the release-config folder.

    For the name of the base Linux image in your desired region, see https://cloud-images.ubuntu.com/locator/ec2/.

    For Windows, refer to the AWS documentation at https://docs.aws.amazon.com/ec2/latest/windows-ami-reference/windows-amis.html.

    To customize other build-time variables, see the "How to run the packer build section" in the /packer/v1/ README in the respective GitHub repository.

  5. To create an AMI for the latest MATLAB release, deploy the Packer build using this command.

    packer build .

    To create the AMI for a previous release, see the Customize Packer Build section in the corresponding GitHub repository.

    To build an AMI for Windows, you also need to set the PACKER_ADMIN_PASSWORD as a command line parameter. This password must be at least 12 characters long, and be a combination of uppercase letters, lowercase letters, numbers, and symbols.

    packer build -var="PACKER_ADMIN_PASSWORD=<password>" .
    

    This command builds an AMI in your AWS account. You are responsible for the storage costs associated with this AMI and its associated snapshot. When you no longer need the AMI, delete it and its associated snapshot.

Find Machine Image ID

When the build finishes, Packer writes the output to a manifest.json file, which contains the artifact_id section. This artifact_id section shows the AMI ID of the machine image generated by the most recent Packer build. Note this value.

Deploy Stack From CloudFormation Template

Create a CloudFormation stack using the JSON template in the releases folder corresponding to the latest release in the GitHub repository. For instructions on how to create a stack, see the AWS documentation at https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-console-create-stack.html. When you deploy the stack, in the Custom AMI ID (Optional) field, use the value of AMI ID from the artifact_id in the manifest.json file.

See Also

Topics

External Websites