1
0
IaC/terraform/hetzner/main.tf

36 lines
723 B
HCL

terraform {
required_version = ">= 1.8.0"
required_providers {
vault = {
source = "hashicorp/vault"
version = ">= 4.2.0"
}
hcloud = {
source = "hetznercloud/hcloud"
version = ">= 1.45"
}
}
backend "local" {
path = "/home/michael/Nextcloud/Backups/tfstate/hetzner.tfstate"
}
}
provider "vault" {
# Export the vault token to the environment variable VAULT_TOKEN
address = "https://vault.balsillie.house"
}
data "vault_kv_secret" "hcloud" {
path = "kv/hcloud"
}
provider "hcloud" {
token = data.vault_kv_secret.hcloud.data.token
}
resource "hcloud_ssh_key" "default" {
name = "default"
public_key = data.vault_kv_secret.hcloud.data.ssh_public_key
}