From e330106e9e6524fc76c407aa608a60ccef83bbe4 Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Mon, 12 Dec 2022 19:41:02 -0800 Subject: infra: add hetzner example --- photo.jinwei.me/infra/.terraform.lock.hcl | 24 ++++++++++++++ photo.jinwei.me/infra/main.tf | 54 +++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 photo.jinwei.me/infra/.terraform.lock.hcl create mode 100644 photo.jinwei.me/infra/main.tf (limited to 'photo.jinwei.me/infra') diff --git a/photo.jinwei.me/infra/.terraform.lock.hcl b/photo.jinwei.me/infra/.terraform.lock.hcl new file mode 100644 index 0000000..6007472 --- /dev/null +++ b/photo.jinwei.me/infra/.terraform.lock.hcl @@ -0,0 +1,24 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hetznercloud/hcloud" { + version = "1.36.1" + constraints = "1.36.1" + hashes = [ + "h1:xZSvxx6aUo0oZp2uqNxi/+wqnCNEBBuu8y7GeXIO9qA=", + "zh:16558b25c7f92f187278e94e951b0ab687882b06acff5b1387f3293f27939f8c", + "zh:28fc79ac2189ff0f5e6c9535ada8f57552b6e21c978b59dc78e086c27b9e4b23", + "zh:373907f9f7f2cefa94e2d5638bf5bef3d3b17e7655dc84dd6089346c6f4f9096", + "zh:394716cd877de682a0772d660f1bdb3838c5d751eca2211105d5ede248c48c39", + "zh:3c438c6590fcc8ac65a10039b2f5ba9ee379a734cb93a59c6cf74f385d891e87", + "zh:3f777a460a62fd23b283c269f1533b3887bf0c5564581e1e96cf294e077f5a8a", + "zh:4f62967553d7ce81ec14db7685306b625970ba6640b5764dc0137675ab97af0b", + "zh:56da08f8d75f596d6f9da4f0fd16bd60d1733cabcc260e885e1d7a711d6d3d8b", + "zh:62776c885bfa8e715dba6662f1744b5251f4cdd523dd4d1e4ccb2e25489593e9", + "zh:64cbb68139aa65f95ab3e654d872f9d34ef991fbf667fc30e0f29b96b5e8b4ed", + "zh:75a4b7a73ff0a537214d12d820438b7ae7a33d660e5d793f4ae0ebe3152bff00", + "zh:7b59d72538772ada7d51eaa50c905285200b1889ab29948b533412ccdf4d18de", + "zh:b84eeaa82bf765c6dd945ae83f1a9271fa5fad53b861b18b09cb8deda67dae13", + "zh:e81c3ea971e32a6ca3fdb0cd9e644614308ab2cf2a19482dd8a109d67fe3fb6f", + ] +} diff --git a/photo.jinwei.me/infra/main.tf b/photo.jinwei.me/infra/main.tf new file mode 100644 index 0000000..aabde19 --- /dev/null +++ b/photo.jinwei.me/infra/main.tf @@ -0,0 +1,54 @@ +terraform { + required_providers { + hcloud = { + source = "hetznercloud/hcloud" + version = "1.36.1" + } + } +} + +variable "hcloud_token" { + sensitive = true +} + +variable "ip_range" { + default = "10.0.1.0/24" +} + +resource "hcloud_ssh_key" "framework" { + name = "framework" + public_key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILS2i5/x9r+cv2j2/SUZ2x2fgQeGnJP1I7PUHC0UdWN6 framework" +} + +data "hcloud_image" "debian" { + name = "debian-11" +} + +resource "hcloud_server" "default" { + name = "photo" + image = data.hcloud_image.debian.name + server_type = "cpx11" + location = "fsn1" + ssh_keys = [hcloud_ssh_key.framework.id] + + public_net { + ipv4_enabled = true + ipv4 = hcloud_primary_ip.primary_ip_1.id + } + delete_protection = false + rebuild_protection = false + + firewall_ids = [hcloud_firewall.default.id] +} + +resource "hcloud_primary_ip" "primary_ip_1" { + name = "primary_ip_test" + datacenter = "fsn1-dc14" + type = "ipv4" + assignee_type = "server" + auto_delete = true +} + +resource "hcloud_firewall" "default" { + name = "default" +} -- cgit v1.2.3