diff options
Diffstat (limited to 'photo.jinwei.me/infra/main.tf')
-rw-r--r-- | photo.jinwei.me/infra/main.tf | 54 |
1 files changed, 54 insertions, 0 deletions
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 | } | ||