diff options
author | clarkzjw <[email protected]> | 2022-12-12 19:41:02 -0800 |
---|---|---|
committer | clarkzjw <[email protected]> | 2022-12-12 19:41:02 -0800 |
commit | e330106e9e6524fc76c407aa608a60ccef83bbe4 (patch) | |
tree | d257f9551a5a1cf900d61f13d1c56a9446b35d9c /photo.jinwei.me | |
parent | 9eb3ea6f7b615c31d7bf53cf1232823e8b8e8a78 (diff) | |
download | jinwei.me-e330106e9e6524fc76c407aa608a60ccef83bbe4.tar.gz |
infra: add hetzner example
Diffstat (limited to 'photo.jinwei.me')
-rw-r--r-- | photo.jinwei.me/infra/.terraform.lock.hcl | 24 | ||||
-rw-r--r-- | photo.jinwei.me/infra/main.tf | 54 |
2 files changed, 78 insertions, 0 deletions
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 @@ | |||
1 | # This file is maintained automatically by "terraform init". | ||
2 | # Manual edits may be lost in future updates. | ||
3 | |||
4 | provider "registry.terraform.io/hetznercloud/hcloud" { | ||
5 | version = "1.36.1" | ||
6 | constraints = "1.36.1" | ||
7 | hashes = [ | ||
8 | "h1:xZSvxx6aUo0oZp2uqNxi/+wqnCNEBBuu8y7GeXIO9qA=", | ||
9 | "zh:16558b25c7f92f187278e94e951b0ab687882b06acff5b1387f3293f27939f8c", | ||
10 | "zh:28fc79ac2189ff0f5e6c9535ada8f57552b6e21c978b59dc78e086c27b9e4b23", | ||
11 | "zh:373907f9f7f2cefa94e2d5638bf5bef3d3b17e7655dc84dd6089346c6f4f9096", | ||
12 | "zh:394716cd877de682a0772d660f1bdb3838c5d751eca2211105d5ede248c48c39", | ||
13 | "zh:3c438c6590fcc8ac65a10039b2f5ba9ee379a734cb93a59c6cf74f385d891e87", | ||
14 | "zh:3f777a460a62fd23b283c269f1533b3887bf0c5564581e1e96cf294e077f5a8a", | ||
15 | "zh:4f62967553d7ce81ec14db7685306b625970ba6640b5764dc0137675ab97af0b", | ||
16 | "zh:56da08f8d75f596d6f9da4f0fd16bd60d1733cabcc260e885e1d7a711d6d3d8b", | ||
17 | "zh:62776c885bfa8e715dba6662f1744b5251f4cdd523dd4d1e4ccb2e25489593e9", | ||
18 | "zh:64cbb68139aa65f95ab3e654d872f9d34ef991fbf667fc30e0f29b96b5e8b4ed", | ||
19 | "zh:75a4b7a73ff0a537214d12d820438b7ae7a33d660e5d793f4ae0ebe3152bff00", | ||
20 | "zh:7b59d72538772ada7d51eaa50c905285200b1889ab29948b533412ccdf4d18de", | ||
21 | "zh:b84eeaa82bf765c6dd945ae83f1a9271fa5fad53b861b18b09cb8deda67dae13", | ||
22 | "zh:e81c3ea971e32a6ca3fdb0cd9e644614308ab2cf2a19482dd8a109d67fe3fb6f", | ||
23 | ] | ||
24 | } | ||
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 @@ | |||
1 | terraform { | ||
2 | required_providers { | ||
3 | hcloud = { | ||
4 | source = "hetznercloud/hcloud" | ||
5 | version = "1.36.1" | ||
6 | } | ||
7 | } | ||
8 | } | ||
9 | |||
10 | variable "hcloud_token" { | ||
11 | sensitive = true | ||
12 | } | ||
13 | |||
14 | variable "ip_range" { | ||
15 | default = "10.0.1.0/24" | ||
16 | } | ||
17 | |||
18 | resource "hcloud_ssh_key" "framework" { | ||
19 | name = "framework" | ||
20 | public_key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILS2i5/x9r+cv2j2/SUZ2x2fgQeGnJP1I7PUHC0UdWN6 framework" | ||
21 | } | ||
22 | |||
23 | data "hcloud_image" "debian" { | ||
24 | name = "debian-11" | ||
25 | } | ||
26 | |||
27 | resource "hcloud_server" "default" { | ||
28 | name = "photo" | ||
29 | image = data.hcloud_image.debian.name | ||
30 | server_type = "cpx11" | ||
31 | location = "fsn1" | ||
32 | ssh_keys = [hcloud_ssh_key.framework.id] | ||
33 | |||
34 | public_net { | ||
35 | ipv4_enabled = true | ||
36 | ipv4 = hcloud_primary_ip.primary_ip_1.id | ||
37 | } | ||
38 | delete_protection = false | ||
39 | rebuild_protection = false | ||
40 | |||
41 | firewall_ids = [hcloud_firewall.default.id] | ||
42 | } | ||
43 | |||
44 | resource "hcloud_primary_ip" "primary_ip_1" { | ||
45 | name = "primary_ip_test" | ||
46 | datacenter = "fsn1-dc14" | ||
47 | type = "ipv4" | ||
48 | assignee_type = "server" | ||
49 | auto_delete = true | ||
50 | } | ||
51 | |||
52 | resource "hcloud_firewall" "default" { | ||
53 | name = "default" | ||
54 | } | ||