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
        • Sharing AMIs with AWS Accounts
      • 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
  • Create custom resources
  • Use custom resources
  • Accessing Resource Outputs
  • Example of Custom AWS Account
  • Terraform Module Examples

Was this helpful?

Edit on GitHub
  1. Sandboxes
  2. Global Sandbox Settings

Custom resources

How to create and use custom resources such as external cloud accounts and leverage them within your Instruqt sandbox.

PreviousSandbox presetsNextCloud services and regions

Last updated 11 months ago

Was this helpful?

Overview

Custom resources allow you to import Terraform modules as resources managed by Instruqt sandboxes. You will need to be comfortable with and the to proceed.

This guide assumes you have published a module to the Terraform Registry. If you are curious to learn more about this feature, please reach out in your Slack organization.

Create custom resources

You can add custom resources (Terraform registry modules) using the Web UI.

  1. Click Settings -> Custom Resources.

  2. Click Import from Terraform Registry. ↳ The Search Terraform Modules page opens.

  3. Search for and click on the Terraform module you wish to import.

  4. In the top-left corner, select the module's version and click Import.

  5. Give you resource a user-friendly name and description then confirm by clicking Import.

Use custom resources

You can add custom resources to sandboxes using the Web UI.

  1. Click the track you want to add custom resources to.

  2. In the Sandbox section of the Track dashboard, click Edit.

  3. On the Sandbox page, click Add a custom resource.

  4. Select the custom resource you want to add.

  5. Input a name, and customize inputs if any are presented.

  6. Click Add resource in the upper-right corner.

The sandbox_id value is a reserved input name, and cannot be used for custom resources.

Accessing Resource Outputs

Custom Resources are provisioned ahead of other sandbox components. Outputs from these Terraform modules are provided as environment variables to host lifecycle scripts. The environment variable will be prefixed with the name given to the custom resource when added to the sandbox.

As an example, if you have a Custom Resource named sqldb that yields an output ENDPOINT, it will be available as an environment variable named $SQLDB_ENDPOINT.

Example of Custom AWS Account

For a walkthrough of how custom resources could be used with an AWS account, review the following video:

Terraform Module Examples

main.tf
resource "aws_instance" "ec2_instance" {
  ami           = var.aws_instance_ami
  instance_type = var.aws_instance_size
  key_name      = var.aws_instance_key

  tags = {
    Name = var.instance_name
  }
}
outputs.tf
output "public_ip" {
  value       = aws_instance.ec2_instance.public_ip
  description = "The public IP address of the deployed EC2 instance"
}
provider.tf
provider "aws" {
  access_key = var.aws_access_key
  secret_key = var.aws_secret_key
  region     = var.aws_instance_region 
}
variable.tf
variable "aws_access_key" {
  description = "AWS Access Key ID"
}

variable "aws_secret_key" {
  description = "AWS Secret Access Key"
}

variable "instance_name" {
  description = "Name of the EC2 instance"
}

variable "aws_instance_ami" {
  description = "ID of the EC2 AMI"
  default     = "ami-0e83be366243f524a"
}

variable "aws_instance_size" {
  description = "Size of the EC2 instance"
  default     = "t2.micro"
}

variable "aws_instance_key" {
  description = "Name of the EC2 key"
  default     = "instruqt"
}

variable "aws_instance_region" {
  description = "Region of the EC2 instance"
  default     = "us-east-2"
}
🏖️
Terraform modules
Terraform Registry