Terraform lets you define cloud infrastructure as code — provision servers, configure DNS and manage resources declaratively.
Install Terraform
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install terraform -y
Hetzner Configuration
resource "hcloud_server" "web" {
name = "web-server-1"
image = "ubuntu-24.04"
server_type = "cx21"
location = "nbg1"
ssh_keys = [hcloud_ssh_key.default.id]
}
Deploy
export TF_VAR_hcloud_token="your-token"
terraform init && terraform plan && terraform apply
Conclusion
Terraform makes infrastructure reproducible. Our team provisions cloud infrastructure using Terraform for repeatable server deployments.
Comments