Main Content

Enable Access to AWS Storage Using Delegation

Since R2023b

MATLAB® Online™ end users can use MATLAB functions to access data stored remotely in AWS® resources such as Amazon S3™. However, if end users do not acquire the AWS credentials needed to access those resources in advance, MATLAB returns an error. If you enable MATLAB Online Server™ to have delegated access to these resources, the server acquires these credentials for end users when they log in to MATLAB Online, providing them immediate access to their remote data.


  • MATLAB Online Server has Transport Layer Security (TLS) enabled. For more details, see the Security configuration properties.

  • You have an AWS account with permission to manage Identity and Access Management (IAM) roles. These permissions enable you to delegate AWS resource access to MATLAB Online Server. For more details, see IAM roles (AWS).

  • You are using a Security Assertion Markup Language (SAML) identity provider to authenticate MATLAB Online users. For details on authenticating MATLAB Online users using SAML, see Configure User Authentication in MATLAB Online Server.

  • Your SAML identity provider uses identity federation and has roles with privileged access to the AssumeRoleWithSAML API.

    • Identity federation is the process of establishing a trust relationship between the identity provider and AWS, enabling the provider to verify user identities and transmit authentication details to AWS. For more details, see About SAML 2.0-based federation (AWS).

    • The AssumeRoleWithSAML API provided by AWS allows the identity provider to assume an IAM role on behalf of the user from within AWS, granting them temporary security credentials for accessing AWS resources.

Configure Authentication Service to Support AWS Delegation

Enable AWS delegation in the MATLAB Online Server authentication service by setting the appropriate values in the authnz.yaml file. The file is located at this path.

  • server_root is the root folder of your MATLAB Online Server installation.

  • cluster is the name of your Kubernetes® cluster.

  • namespace is the Kubernetes namespace you used to deploy MATLAB Online Server.

Under identityProviders, within the saml identity provider, add a delegation section with this structure.

  - id: saml
    type: saml
    # Standard SAML Configuration

          failureMode: "halt"
            region: "us-east-1"
            sessionDuration: 3600

For details on the standard SAML configuration, see the SAML section of the authentication documentation.

In the delegation section, configure these attributes.

AttributeOptional or RequiredDescription

Action that the authentication provider takes when a delegation request fails.

  • "bypass" (default) — Process the failed delegation request as a warning and enable the end user to log in to MATLAB Online.

  • "halt" — Process the failed delegation request as an error and do not log the end user in to MATLAB Online.

regionRequiredRegion of the AWS resources being accessed. Example: "us-east-1"

Amount of time, in seconds, that users have access to AWS resources.

If you enable delegation, when an end user logs into MATLAB Online, AWS grants the user access to AWS resources for a fixed session duration. When this session expires, to access AWS resources again, the user must sign out and sign back in to MATLAB Online.

MATLAB Online Server sets the session duration based on these rules.

  1. If specified, the server sets the duration to the sessionDuration value set in authnz.yaml.

  2. If sessionDuration is not specified, the server sets the duration to this session duration attribute in the identity provider configuration:

  3. If the session duration of the identify provider is not configured, the server sets the duration to the default value specified by the security token service that AWS uses to access the resource.

sessionDuration must not exceed the MaxSessionDuration value set in your IAM role in AWS. For more details, see Update MaxSessionDuration (AWS).

Deploy Kubernetes Secret for AWS User Credentials

To transmit the AWS credentials of end users within the MATLAB Online Server cluster, deploy a Kubernetes secret to the cluster. A Kubernetes secret is an object that encrypts sensitive data so that it can be shared securely between services within the cluster. You must deploy this secret within the same namespace as other MATLAB Online Server services in your Kubernetes cluster.

To deploy a Kubernetes secret to the cluster:

  1. Generate a random 64-bit-encoded string that the cluster can use to encrypt the data. For example, this Linux® bash script generates a random string of alphanumeric characters wrapped onto lines of 32 characters each, and then encodes the string using base-64 encoding.

    SECRET=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
    echo $SECRET
    echo -n $SECRET | base64
  2. Create a file named credentials-secret.yaml and copy in the fields shown. Then, set the credentials-secret field to the value of the base-64-encoded string generated earlier. Save the file in any location within the Kubernetes cluster.

    apiVersion: v1
    kind: Secret
        name: credentials-secret
        credentials-secret: <secret string>
  3. Deploy the secret to the Kubernetes cluster. Replace your-namespace with your MATLAB Online Server namespace.

    kubectl apply -f credentials-secret.yaml --namespace your-namespace

Enable AWS Access Across Server

Enable all services to have delegated access to AWS resources by setting the appropriate values in the all.yaml file. The file is located at this path.


In the global section, add a delegation section with this structure.

    enabled: true
      - type: "awsiam"
        enabled: true
      mountPath: "/etc/credentials-secret-volume/"
      name: "credentials-secret"

Configure these attributes.

AttributeOptional or RequiredDescription

Delegation provider. To enable AWS delegation, type must be "awsiam" and enabled must be true.


Full path to the secret file used for securely transmitting AWS credentials within the MATLAB Online Server cluster.

  • mountPath specifies the location to which you deployed the secret. The default mount path is "/etc/credentials-secret-volume".

  • name is the name of the secret file, as determined by the name field of credentials-secret.yaml. The default name is credentials-secret, as shown in the name field specified in the Deploy Kubernetes Secret for AWS User Credentials step.

If you do not change the default values, then you can omit the secretFile section.

Deploy Changes to Server

To apply your changes, undeploy and redeploy the server.

./mosadm undeploy
./mosadm deploy

These changes take effect the next time that MATLAB Online end users log in with their single sign-on credentials.

For an example of how end users can access their remote data, see Work with Remote Data. When delegation is enabled, end users do not have to follow the instructions on setting up access and setting environment variables for their credentials.

Related Topics