Skip to main content
All CollectionsVPSAPI
Getting started with the Hostinger Terraform provider

Getting started with the Hostinger Terraform provider

Learn how to manage your Hostinger infrastructure efficiently using the Hostinger Terraform provider

Updated this week

The Hostinger Terraform provider enables infrastructure management via Terraform's Infrastructure as Code (IaC) methodology. With this provider, you can automate the deployment and management of your Hostinger resources, such as VPS instances, DNS zones, and DNS records.

Provider Setup

To get started, first define the Hostinger provider within your Terraform configuration:

terraform {
required_providers {
hostinger = {
source = "hostinger/hostinger"
version = "0.1.3"
}
}
}

provider "hostinger" {
api_token = "your_hostinger_api_token"
}

Replace your_hostinger_api_token with your Hostinger API token, which you can obtain from your Hostinger account's API settings.

Example usage

Creating a VPS instance

Here's how you can create a new VPS instance:

resource "hostinger_vps" "box" {
plan = "hostingercom-vps-kvm2-usd-1m"
data_center_id = 13
template_id = 1002
hostname = "web-01.example.com"
password = "SecureP@ssw0rd!"
post_install_script_id = hostinger_vps_post_install_script.nginx.id
ssh_key_ids = [hostinger_vps_ssh_key.inline_key.id]
}

Applying Configuration

After defining your resources, run:

terraform init
terraform plan
terraform apply

Terraform will prompt you to confirm the changes. Once confirmed, Terraform will provision your Hostinger resources.

Explore further capabilities by checking the official documentation:

Integrating Terraform into your workflow allows efficient, reproducible management of your Hostinger infrastructure, enabling you to scale seamlessly

Did this answer your question?