Quick, no-nonsense guide on using the OVH Terraform provider to deploy and manage cloud instances with OpenStack. Our Live Support Team is always here to help you.
OVH Terraform Provider – Quick Guide to Deploy Your First Instance
Setting up servers through the OVH dashboard works, but it can be slow and repetitive. Using the ovh terraform provider makes the process faster, more consistent, and easier to repeat. With a few small configuration files and a single command, new instances can be deployed in minutes.
This guide covers the complete process, installing Terraform, configuring the OVH provider, adding an SSH key, launching an instance, retrieving its public IP, and removing it when it’s no longer needed. Every command and file needed is included, so the setup can be followed from start to finish without guesswork.
An Overview
Installing Terraform
Terraform, created by HashiCorp, is an open-source Infrastructure as Code tool. It uses HCL (HashiCorp Configuration Language) to describe your infrastructure. Download Terraform from HashiCorp’s official page.
Once downloaded, unzip the package. Terraform is a single binary named terraform. Move it to a folder in your $PATH:
$ mv ~/Downloads/terraform /usr/local/bin/
Confirm the installation:
$ terraform -help
Setting Up the OVH Terraform Provider
First, create an OpenStack user in your OVH Public Cloud account and get your openrc.sh file. If you don’t have it, follow this guide: OVH API OpenStack setup.
Load your credentials:
$ source openrc.sh
Please enter your OpenStack Password:
Check available instance models:
$ openstack flavor list
Preparing Your Terraform Files
Make a working directory:
$ mkdir ~/terraform-ovh && cd $_
providers.tf – Declaring the OVH Provider
provider "openstack" {
auth_url = "https://auth.cloud.ovh.net/v3.0/"
domain_name = "default" # Nom de domaine - Toujours à "default" pour OVH
alias = "ovh"
#vos accès OpenStack
user_name = "xxxxx"
password = "xxxxxxxxxxxxxxxxx"
}
instance.tf – Adding SSH Key and Instance
#Déclaration d'une ressouce pour ajouter ma clé SSH sur OpenStack
resource "openstack_compute_keypair_v2" "My-Key" {
provider = openstack.ovh
name = "My-Key"
public_key = file("~/.ssh/id_rsa.pub")
}
#Déclaration de l'instance à créer
resource "openstack_compute_instance_v2" "test_terraform_instance" {
name = "terraform_instance"
provider = openstack.ovh
image_name = "Ubuntu 20.04"
flavor_name = "s1-2"
key_pair = openstack_compute_keypair_v2.My-Key.name
network {
name = "Ext-Net"
}
}
Your folder should now look like this:
.
├── instance.tf
└── providers.tf
Initializing and Deploying
Run:
$ terraform init
Then:
$ terraform apply
Type yes to confirm. Terraform will create your SSH key and launch your instance.
Getting the Public IP
$ openstack server list
Connect via SSH:
$ ssh ubuntu@X.X.X.X
Removing the Instance
When you’re done:
$ terraform destroy
Confirm with yes. This deletes the instance and keypair.
[If needed, Our team is available 24/7 for additional assistance.]
Conclusion
With said, by following these commands and file setups exactly, you can use the ovh terraform provider to deploy, connect to, and remove cloud instances quickly. It’s a direct way to manage infrastructure without manual errors and repetitive console work. If you’re building more complex setups later, this foundation will carry over.
0 Comments