Created
September 9, 2025 09:08
-
-
Save bjarneo/a50673e4cc8a1686c0bb703aeb154b16 to your computer and use it in GitHub Desktop.
sandbox_vps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| variable "hcloud_token" {} | |
| # Configure the Hetzner Cloud Provider | |
| provider "hcloud" { | |
| token = var.hcloud_token | |
| } | |
| resource "hcloud_server" "server" { | |
| name = "sandbox1" | |
| server_type = "cx22" | |
| image = "ubuntu-24.04" | |
| location = "hel1" # Helsinki | |
| ssh_keys = [hcloud_ssh_key.default.id] | |
| firewall_ids = [hcloud_firewall.myfirewall.id] | |
| } | |
| # Add your local SSH public key to access the server using SSH | |
| resource "hcloud_ssh_key" "default" { | |
| name = "local ssh key" | |
| public_key = file("~/.ssh/x_hetzner.pub") | |
| } | |
| resource "hcloud_firewall" "myfirewall" { | |
| name = "my-firewall" | |
| rule { | |
| direction = "in" | |
| protocol = "tcp" | |
| port = "22" | |
| # NOTE: restrict the ip list to your private ip | |
| # This allows all ipv4 and ipv6 to access the port 22 | |
| source_ips = [ | |
| "0.0.0.0/0", | |
| "::/0" | |
| ] | |
| } | |
| } | |
| output "server_ip" { | |
| value = hcloud_server.server.ipv4_address | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment