Terraform Hetzner Setup
This Terraform configuration creates a single Hetzner Cloud server in Nuremberg and manages an SSH key. It also outputs the IPv4 and IPv6 addresses of the server.
⚠️ Note: Hetzner Cloud Terraform provider does not support object storage buckets natively. You will need to create any buckets manually or use an S3-compatible provider.
Project Structure
terraform-hetzner/ ├── main.tf # SSH key, server resource ├── provider.tf # Hetzner provider configuration ├── variables.tf # Input variables (API token) ├── outputs.tf # Outputs IPv4 and IPv6 addresses
Prerequisites
- Terraform >= 1.3
- Hetzner Cloud account
- Hetzner Cloud API token
- Your SSH public key
Steps to Run
- Clone this repository or copy the files to a folder:
git clone <your-repo-url>
cd terraform
2. Set your Hetzner API token in the environment
export HCLOUD_TOKEN="your-api-token"
4. Initialize Terraform
terraform init
terraform apply -var="hcloud_token=$HCLOUD_TOKEN"
Description
Languages
HCL
60.2%
Jinja
39.8%