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:
- Terraform installed
- An account at https://www.letscloud.io
- Your LetsCloud API Token from: https://my.letscloud.io/profile/client-api
- An SSH key added to your account at: https://my.letscloud.io/profile/ssh-keys
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
- Upload your public SSH key at: https://my.letscloud.io/profile/ssh-keys
- 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
- You can destroy the VM with
terraform destroy
- Change
plan_slug
to resize your VM - Change
location_slug
for other regions likeNYC1
,LON1
, etc. - Full documentation available at: https://github.com/letscloud-community/terraform-provider-letscloud
0 COMMENTS