Instruqt Docs
  • 🚩Getting started
    • Overview
    • Setting up
      • Study Room
    • Quickstart
  • 🛤️Tracks
    • Manage tracks
      • Create tracks
      • Edit locally
      • Test tracks
      • Track logs
      • Track time limits
      • Track feedback
      • Developer workflow
      • Track tags
      • Track authors
      • Delete tracks
      • Custom layouts
      • Version control
      • Loading experience
    • Challenges
      • Create challenges
      • Challenge tabs
      • Challenge order
      • Skip challenges
      • Add quizzes
      • Assignment display
      • Assignment editor
    • Share tracks
      • Live Events
        • Instructor tools
      • Track invites
      • Embed tracks
      • Landing pages
  • 🏖️Sandboxes
    • Overview
    • Sandbox hosts
      • Add hosts
      • Custom VM images
      • Custom container images
      • Public images
      • Windows VMs
      • Website service
      • SSL certificates
    • Cloud accounts
      • Securing your cloud accounts
      • Cloud Client
      • AWS accounts
        • AWS Environment Variables
        • AWS Managed Policies
        • AWS IAM Policies
        • AWS SCP Policies
      • Azure subscriptions
        • Azure Environment Variables
        • Azure Roles
        • Azure Resource Providers
      • GCP projects
        • GCP Environment Variables
        • GCP IAM Permissions
    • Lifecycle scripts
      • Scripting overview
      • Track scripts
      • Challenge scripts
      • Example scripts
      • Helper scripts
    • UI Checks
    • Global Sandbox Settings
      • Hot start
      • Sandbox presets
      • Custom resources
      • Cloud services and regions
        • Allowed services and regions
    • Secrets and variables
      • Runtime variables
      • Runtime parameters
      • Secrets
  • ⚙️Settings
    • Integrations
      • Salesforce (Beta)
      • HubSpot (Beta)
      • HubSpot (Using zapier)
      • LTI
      • Version control
        • GitHub
    • Authentication
      • SSO
      • API keys
    • Platform
      • API
      • Webhooks
      • Track limits
  • 💡Reference
    • Feature overview
    • Instruqt CLI
      • Commands
      • Configuration files
      • Assets
    • Instruqt platform
      • Networking
      • Host machine types
      • Quotas and limits
      • Roles and permissions
      • Network access
      • Requirements
  • 🛟Resources
    • Content design tips
    • Advanced use cases
    • Templates
    • FAQ
      • Running Windows Client Hosts on Instruqt
      • Using Cleanup Scripts in SaaS and Cloud Environments
      • Instruqt Regional Configurations and Restrictions
      • Troubleshooting Instruqt CLI Authentication Issues
      • Copy a Track from One Organization to Another via CLI
      • Network Configuration: IP and MAC Address Control
      • Container Troubleshooting in Instruqt
Powered by GitBook
On this page
  • Overview
  • Set variables
  • Use variables

Was this helpful?

Edit on GitHub
  1. Sandboxes
  2. Secrets and variables

Runtime variables

How to define runtime variables and use them inside lifecycle scripts or challenge assignments.

PreviousSecrets and variablesNextRuntime parameters

Last updated 1 year ago

Was this helpful?

Overview

Runtime variables allow you to use dynamic content in challenge assignments and lifecycle scripts. You can define runtime variables via our or . These variables are configured per participant per host (e.g a user's VM or container) and can only be accessed from the given participant and host.

It's not recommended to store secrets in runtime variables as the storage is not secure and everyone who has terminal access may be able to view them. Furthermore, cloud account related environment variables are automatically stored in the $INSTRUQT_ENV_VARS variable, and do not need to be redefined as runtime variables.

Set variables

Define variables

You can define variables in lifecycle scripts on Linux and Windows hosts:

agent variable set <KEY> <VALUE>

For example, the following defines a runtime variable named COLOR with a value of RED.

agent variable set COLOR RED
Agent-Variable-Set <KEY> <VALUE>

For example, the following defines a runtime variable named COLOR with a value of RED.

Agent-Variable-Set COLOR RED

Retrieve variables

In order to retrieve the value of a runtime variable, use the following command:

agent variable get {KEY}

For example, the following retrieves a runtime variable named COLOR.

agent variable get COLOR
Agent-Variable-Get {KEY}

For example, the following retrieves a runtime variable named COLOR.

Agent-Variable-Get COLOR

Use variables

To retrieve the value of a runtime variable in a challenge assignment use following syntax:

[[ Instruqt-Var key="<KEY>" hostname="<HOSTNAME>" ]]

Where KEY is a key you registered a value with and HOSTNAME is a host where the variable resides.

You can only access variables via lifecycle scripts, the GraphQL API, or assignment markdown. It is not possible to get/set them from a terminal session on a host.

Example

Consider the following challenge assignment, which references a runtime variable named INSTRUQT_TEST_VAR on a host named cloud-client.

👋 Introduction
===============

The following line contains the value of INSTRUQT_TEST_VAR: 
[[ Instruqt-Var key="INSTRUQT_TEST_VAR" hostname="cloud-client" ]]

Assuming INSTRUQT_TEST_VAR was registered with a value of TEST123 on the cloud-client host during its setup script, the assignment text would display TEST123 to the user.

🏖️
API
Lifecycle Scripts