Skip to content

Commit

Permalink
tf: add support for ssh_keys
Browse files Browse the repository at this point in the history
Signed-off-by: Sefa Eyeoglu <[email protected]>
  • Loading branch information
Scrumplex committed Nov 29, 2024
1 parent 9ed6029 commit 8aa0898
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
locals {
user_keys_path = "${path.root}/keys/users"
user_keys = { for f in fileset(local.user_keys_path, "*.pub") : trimsuffix(f, ".pub") => file("${local.user_keys_path}/${f}") }
}

resource "hcloud_ssh_key" "user_keys" {
for_each = local.user_keys
name = each.key
public_key = each.value
}

resource "hcloud_server" "andesite" {
name = "andesite"
image = "ubuntu-22.04"
Expand All @@ -7,6 +18,12 @@ resource "hcloud_server" "andesite" {
ipv4_enabled = true
ipv6_enabled = true
}

ssh_keys = [for k in hcloud_ssh_key.user_keys : k.id]

lifecycle {
ignore_changes = [ssh_keys]
}
}

resource "netlify_dns_zone" "prismlauncher" {
Expand Down

0 comments on commit 8aa0898

Please sign in to comment.