Links

Runtime variables

This page describes how to define runtime variables and use them inside lifecycle scripts or challenge assignments.
Runtime variables are key-value pairs which can be registered via GraphQL API or Lifecycle Scripts and displayed in challenge markdown. These variables are configured per participant per host (e.g your vm or container instance) and can only be accessed from the given participant and host.
By default we register all key/value pairs which are inside $INSTRUQT_ENV_VARS environment variable. So all cloud accounts credentials will be registered by default and you don’t have to do it yourself.
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.

Variables usage via GraphQL API

Register key-value pair

SetSandboxVariable mutation registers the variable with the given key and value on the given participant and host.
mutation setVariable($sandboxID: String!, $hostname: String!, $key: String!, $value: String!) {
setSandboxVariable(sandboxID: $sandboxID, hostname: $hostname, key: $key, value: $value) {
key
value
}
}
Where $sandboxID is your participant ID and $hostname is the name of your configured host (container or VM).

Retrieve value

GetSandboxVariable query retrieves variable value with the given key.
query getVariable($sandboxID: String!, $hostname: String!, $key: String!) {
getSandboxVariable(sandboxID: $sandboxID, hostname: $hostname, key: $key) {
key
value
}
}
Where $sandboxID is your participant ID and $hostname is a name of your configured host (container or VM).

Variables usage in Lifecycle Scripts

Register key-value pair

agent variable set {key} {value} , where {key} is case-insensitive key for your value and value is value
Agent-Variable-Set {key} {value} - alternative version for windows host.

Retrieve value

agent variable get {key} , where {key} is case-insensitive key
Agent-Variable-Get {key} - alternative version for windows host.

Usage in challenge assignment markdown

To refer to the value of your variable you can use following syntax:
[[ Instruqt-Var key="INSTRUQT_TEST_VAR" hostname="cloud-client" ]]
Where key is a key you registered a value with and hostname is a host where variable is registered.

Example challenge markdown

👋 Introduction
===============
Following value is registered with a key INSTRUQT_TEST_VAR: [[ Instruqt-Var key="INSTRUQT_TEST_VAR" hostname="cloud-client" ]]
To complete this challenge, press **Check**.

Things to keep in mind
🤔

  • By default we register all key/value pairs which are inside $INSTRUQT_ENV_VARS environmental variable. So all cloud accounts credentials will be registered by default and you don’t have to do it yourself.
  • You can access variables only via lifecycle scripts, GraphQL API or assignment markdown. It is not possible to get/set them from terminal session.
  • Keys are case-insensitive.