1
- # This file only list our user's email and public keys,
2
- # so those can be re-used elsewhere (e.g.: hcloud, gandi, ...)
1
+ # This file is where we define all our users and their attributes (e.g.: email, keys, ...) ,
2
+ # so those can be re-used with different providers (e.g.: aws, hcloud, gandi, ...)
3
3
locals {
4
4
users = {
5
5
benoit = {
6
6
email = " benoit@leastauthority.com" ,
7
7
ssh_keys = [
8
8
{
9
- id = " 000619776016" ,
9
+ id = " 000619776016" , # could be anything, but unique per user
10
10
key = " ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIZtWY7t8HVnaz6bluYsrAlzZC3MZtb8g0nO5L5fCQKR benoit@leastauthority.com" ,
11
11
},
12
12
],
@@ -15,14 +15,17 @@ locals {
15
15
email = " florian@leastauthority.com" ,
16
16
ssh_keys = [
17
17
{
18
- id = " 000018054987" ,
18
+ id = " 000018054987" , # could be anything, but unique per user
19
19
key = " ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJlPneIaRT/mqu13N83ctEftub4O6zAfi6qgzZKerU5o florian@leastauthority.com" ,
20
20
},
21
21
],
22
22
},
23
23
}
24
24
25
- # Flatten all the ssh keys of each users
25
+ # In many cases, the ssh keys from all the users above will be authorized to access some ressources
26
+ # (e.g.: a new server). So we better collect all the ssh keys together in a local variable,
27
+ # and give them a unique name (e.g.: one username with multiple keys)
28
+ #
26
29
ssh_keys = flatten ([
27
30
for username , values in local . users : [
28
31
for v in values . ssh_keys : {
@@ -33,7 +36,8 @@ locals {
33
36
])
34
37
}
35
38
36
- # Manage ssh keys
39
+ # Now we have all the ssh keys of all our users, we can deploy and manage them
40
+ # so Hetzner can use to provision our resources (e.g.: new VPS)
37
41
resource "hcloud_ssh_key" "ssh_keys" {
38
42
for_each = {
39
43
for key in local . ssh_keys : " tf-${ key . name } " => key . public_key
0 commit comments