Instruqt Labs (beta)
  • Instruqt
  • Getting started
    • Setting up Version Control
    • Install Instruqt CLI
    • Creating your first lab
    • Configuration basics
    • Exploring the lab configuration
    • Adding your first chapter
    • Configuring sandboxes
    • Adding quizzes
    • Adding tasks and gating content
    • Finishing up
  • Documentation
    • Writing Lab Content
      • Project Structure
      • Markdown and Components
    • Integrations
      • Version Control
    • Lab reference
      • Content
        • Lab
        • Page
        • Activities
          • Task
          • Quiz
            • Multiple Choice
            • Single Choice
            • Text Answer
            • Numeric Answer
        • Layout
        • Tabs
          • Terminal
          • Service
          • Editor
          • External Website
          • Note
      • Sandbox
        • Containers
          • Container
          • Sidecar Container
        • Kubernetes
          • Cluster
          • Config
          • Helm
        • Nomad
          • Cluster
          • Job
        • Networking
          • Network
          • Ingress
        • Cloud Accounts
          • AWS
          • Azure
          • Google Cloud
        • Terraform
        • Template
        • Exec
        • Copy
        • Certificates
          • Root
          • Leaf
        • Random
          • Number
          • ID
          • UUID
          • Password
          • Creature
      • Functions
    • Tools
      • Instruqt CLI
    • Glossary
Powered by GitBook
On this page
  • Attributes
  • Types
  • Expressions
  • Functions
  • Blocks
  • Comments
Edit on GitHub
Export as PDF
  1. Getting started

Configuration basics

This guide introduces the core concepts of writing configuration and the used syntax.

The configuration is structured around a few key elements:

  • Blocks: Containers for configuration, such as resource, variable, or module.

  • Attributes: Key-value pairs that assign settings or data within a block.

  • Expressions: Code that resolves to a value, used to calculate or reference dynamic content.

  • Functions: Built-in operations that transform or generate values.

  • Comments: Lines ignored by the parser, useful for documentation.

resource "container" "my_container" {
  image {
    name = "redis:latest"
  }

  volume {
    source = "./files"
    destination = "/tmp/files"
  }
}

Attributes

Attributes are key-value pairs that define configuration data inside a block.

name = "redis:latest"

Here name is the attribute name and "redis:latest" is its value.

Attributes can be either static (e.g. strings, numbers) or dynamic values calculated by using expressions or functions.

Types

Several basic and complex data types for attribute values are supported:

Basic types

  • String "example"

  • Number: 42, 3.14

  • Boolean: true, false

Complex types

  • List: An ordered sequence

    ports = [80, 443]
  • Map: Key-value pairs

    environment = {
      name = "web-server"
      env  = "prod"
    }
  • Tuple: A fixed-length list of values of possibly different types

    mixed = [1, "two", true]
  • Object: A structure with named attributes and types

    server = {
      id   = 123
      name = "db-server"
    }

Expressions

Expressions are used to compute or reference values. They can be:

  • literal values: for instance "hello" or 42

  • references: pointing to another value

    name = variable.redis_image
  • operations: for instance arithmetic, logical, or string operations

    nodes = variable.node_count + 1

Functions

Instruqt provides built-in functions to transform or generate data within expressions. Examples include:

  • len() – returns the length of a list or string

  • lower() – converts a string to lowercase

  • join() – joins list elements into a single string

  • file() – reads the contents of a file

name = lower("MyServer")

Blocks

Blocks define containers for configuration and typically follow this format:

block_type "label1" "label2" {
  attribute1 = "value"
  attribute2 = 123

  nested_block_type "label1" {
    nested_attribute1 = "value"
  }
}

Available top level block types are:

  • resource

  • module

  • variable

  • local

  • output

variable "my_variable" {
  default = "my-default-value"
}

Each block can have:

  • A block type (e.g., resource)

  • One or more labels (identifiers)

  • A body containing attributes and nested blocks

Comments

The configuration supports two types of comments:

  • Single-line comments:

    • Using #

    • Using //

  • Multi-line comments:

    • Using /* */

/*
  This is a
  multi-line comment
*/
PreviousCreating your first labNextExploring the lab configuration

Last updated 6 days ago