Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit db360b6

Browse files
committed
example: generate dummy ssh private key for hetzner cloud
1 parent 87a4e48 commit db360b6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

examples/hetzner-linux/main.tf

+12
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,24 @@ resource "coder_app" "code-server" {
9191
relative_path = true
9292
}
9393

94+
# Generate a dummy ssh key that is not accessible so Hetzner cloud does not spam the admin with emails.
95+
resource "tls_private_key" "rsa_4096" {
96+
algorithm = "RSA"
97+
rsa_bits = 4096
98+
}
99+
100+
resource "hcloud_ssh_key" "root" {
101+
name = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}-root"
102+
public_key = tls_private_key.rsa_4096.public_key_openssh
103+
}
104+
94105
resource "hcloud_server" "root" {
95106
count = data.coder_workspace.me.start_count
96107
name = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}-root"
97108
server_type = var.instance_type
98109
location = var.instance_location
99110
image = var.instance_os
111+
ssh_keys = [hcloud_ssh_key.root.id]
100112
user_data = templatefile("cloud-config.yaml.tftpl", {
101113
username = data.coder_workspace.me.owner
102114
volume_path = "/dev/disk/by-id/scsi-0HC_Volume_${hcloud_volume.root.id}"

0 commit comments

Comments
 (0)