If you're looking for a fast and reliable way to provision virtual machines in Brazil using Terraform, LetsCloud is a great choice. In this guide, you'll learn step-by-step how to launch an Ubuntu 24.04 LTS instance in the São Paulo region using the official LetsCloud Terraform provider.

Prerequisites

Before getting started, you need:

Project structure

Create a folder named letscloud-vm and inside it, create the file main.tf with the following content:

terraform {
  required_providers {
    letscloud = {
      source  = "letscloud-community/letscloud"
      version = "~> 1.0.0"
    }
  }
}

provider "letscloud" {
  api_token = var.letscloud_api_token
}

data "letscloud_ssh_key_lookup" "admin" {
  label = var.letscloud_ssh_key
}

resource "letscloud_instance" "server" {
  label         = "web-server"
  plan_slug     = "1vcpu-2gb-20ssd"
  image_slug    = "ubuntu-24.04-x86_64"
  location_slug = "SAO2"
  hostname      = "web.example.com"

  ssh_keys = [data.letscloud_ssh_key_lookup.admin.id]

  password = "P@ssw0rd123!Secure"
}

Also create a file named variables.tf:

variable "letscloud_api_token" {
  description = "Your LetsCloud API token"
  type        = string
}

variable "letscloud_ssh_key" {
  description = "Label (name) of your SSH key registered in LetsCloud"
  type        = string
}

Optionally, you may create a terraform.tfvars file:

letscloud_api_token = "your_api_token_here"
letscloud_ssh_key   = "your_ssh_key_label"

How to find your SSH key label

  1. Upload your public SSH key at: https://my.letscloud.io/profile/ssh-keys
  2. Copy the label (name) shown after the upload. Use this as the label in your variables.

Running Terraform

Run the following commands:

terraform init
terraform plan
terraform apply

Confirm with yes when prompted. In a few minutes, your Ubuntu 24.04 VM will be running in the São Paulo region.


Expected result

  • Active instance with Ubuntu 24.04
  • Public IP assigned
  • SSH access enabled using your uploaded key

Final tips

Read more about: Operating SystemUbuntu