May 26, 2023

Harness the Power of Terraform with Crusoe Cloud

Crusoe x Terraform

Crusoe x Terraform

Crusoe is excited to announce support for managing infrastructure using Terraform. As part of a larger DevOps strategy, Terraform, an open-source infrastructure as code (IaC) tool, has gained immense popularity for its ability to provision, manage, and automate infrastructure resources. In this article, we will explore how Terraform can be seamlessly integrated with Crusoe Cloud, our climate-aligned cloud platform, to simplify infrastructure management.

What is Terraform?
Terraform is a declarative configuration language and orchestration tool designed to manage infrastructure resources across multiple cloud providers and services. It allows users to define their infrastructure as code, enabling consistent, repeatable, and version-controlled provisioning of resources.

Getting Started with Terraform and Crusoe Cloud:
To start using Terraform

with Crusoe Cloud, follow these steps:

Step 1: Install Terraform

Visit the Terraform website ( and download the latest version of Terraform suitable for your operating system. Follow the installation instructions provided.

Step 2: Prepare your Crusoe Cloud Account

If you haven’t already, upload your SSH key to the Crusoe console and create new API tokens.

Once you've created a token keypair, add the credentials to your ~/.crusoe/config like so:


Note: this is also the file used for authenticating with the Crusoe CLI!

Step 3. Getting started with Terraform
As of today, the Crusoe Terraform provider supports launching VMs with provisioning startup/shutdown scripts, as well as creating and attaching disks. We also have support for creating firewall rules for the networking subnet.

To get started, create a file that contains the following:

terraform {
  required_providers {
    crusoe = {
      source = "crusoecloud/crusoe"
      version = "0.2.1"

locals {
my_ssh_key = file(<path/to/>)

Make sure to substitute the the full path of the public side of the key pair for my_ssh_key, which we will use when configuring access to VMs.

We can now define resources to provision. To create a VM, add the following code block:

resource "crusoe_compute_instance" "my_instance" {
name = "my-instance"
type = "a40.1x"
ssh_key = local.my_ssh_key
disks = [

resource "crusoe_storage_disk" "data_disk" {
name = "data-disk"
size = "200GiB"

This code snippet creates an instance called "my-instance" that contains a single NVIDIA A40 GPU. It also creates a disk called "data-disk" 200 GiB in size, which will be attached at launch.

Step 4. Execute provisioner

In the same directory as the file we created, we first need to initialize the provider, by downloading the latest version from the registry. This step only needs to be done once per project.

terraform init

We can then ensure that all resources are going to be created as expected with the following command:

terraform plan

and then run apply to actually build the resources:

terraform apply

Once the provisioning is complete, you can check the Crusoe Console or use the Crusoe CLI to get the public IP to ssh into the VM. When you want to clean up resources, stop the VM from the console, and detach any disks. Then, you can use the following command:

terraform destroy

While our brief example created a single VM and disk, Terraform unlocks the ability to orchestrate and provision sophisticated architectures on Crusoe Cloud for various machine learning, graphics, and rendering workflows. And we’re just getting started, with improvements and new features to come as we continue to roll out products around SLURM, kubernetes, custom images, large scale inference deployments, and more. For more details, usage examples, and to contribute back to the provider, check out our open source GitHub project. For any questions or feature requests, we invite you to reach out to [email protected]; otherwise, go power up your infrastructure with Terraform on Crusoe Cloud!

Liked what you just read? Share it

Relevant Articles

View all