Skip to content

Commit

Permalink
Better comment for the definition of the users
Browse files Browse the repository at this point in the history
Signed-off-by: Benoit Donneaux <[email protected]>
  • Loading branch information
btlogy committed Jan 31, 2025
1 parent 67392a2 commit f0d5f4c
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tf/core/users.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# This file only list our user's email and public keys,
# so those can be re-used elsewhere (e.g.: hcloud, gandi, ...)
# This file is where we define all our users and their attributes (e.g.: email, keys, ...),
# so those can be re-used with different providers (e.g.: aws, hcloud, gandi, ...)
locals {
users = {
benoit = {
email = "[email protected]",
ssh_keys = [
{
id = "000619776016",
id = "000619776016", # could be anything, but unique per user
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIZtWY7t8HVnaz6bluYsrAlzZC3MZtb8g0nO5L5fCQKR [email protected]",
},
],
Expand All @@ -15,14 +15,17 @@ locals {
email = "[email protected]",
ssh_keys = [
{
id = "000018054987",
id = "000018054987", # could be anything, but unique per user
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJlPneIaRT/mqu13N83ctEftub4O6zAfi6qgzZKerU5o [email protected]",
},
],
},
}

# Flatten all the ssh keys of each users
# In many cases, the ssh keys from all the users above will be authorized to access some ressources
# (e.g.: a new server). So we better collect all the ssh keys together in a local variable,
# and give them a unique name (e.g.: one username with multiple keys)
#
ssh_keys = flatten([
for username, values in local.users : [
for v in values.ssh_keys : {
Expand All @@ -33,7 +36,8 @@ locals {
])
}

# Manage ssh keys
# Now we have all the ssh keys of all our users, we can deploy and manage them
# so Hetzner can use to provision our resources (e.g.: new VPS)
resource "hcloud_ssh_key" "ssh_keys" {
for_each = {
for key in local.ssh_keys : "tf-${key.name}" => key.public_key
Expand Down

0 comments on commit f0d5f4c

Please sign in to comment.