Skip to content

Commit 463cd68

Browse files
committed
Use github account SSH key instead of a hardcoded one
1 parent 71cb4b1 commit 463cd68

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ tf-plan:
88

99
.PHONY: tf-apply
1010
tf-apply:
11-
terraform -chdir=./terraform apply
11+
terraform -chdir=./terraform apply -var-file=../terraform.tfvars
1212

1313
.PHONY: ansible-run
1414
ansible-run:

terraform/main.tf

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ terraform {
44
source = "hetznercloud/hcloud"
55
version = "1.32.2"
66
}
7+
github = {
8+
source = "integrations/github"
9+
version = "~> 4.0"
10+
}
711
}
812
}
913

@@ -13,10 +17,21 @@ variable "hcloud_token" {
1317
sensitive = true
1418
}
1519

20+
variable "github_user" {
21+
type = string
22+
description = "The Github user account which first SSH key is used"
23+
}
24+
1625
provider "hcloud" {
1726
token = var.hcloud_token
1827
}
1928

29+
provider "github" {}
30+
31+
data "github_user" "my_user" {
32+
username = var.github_user
33+
}
34+
2035
resource "hcloud_network" "kubernetes_network" {
2136
ip_range = "10.0.0.0/16"
2237
name = "network-kubernetes"
@@ -36,7 +51,7 @@ resource "hcloud_placement_group" "group_spread" {
3651

3752
resource "hcloud_ssh_key" "ssh_key_zolli" {
3853
name = "key_zolli"
39-
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDEx60XjFcsAk1n2C8+1RtQ/J3p+eJWlCIBCsI8LMnVoWcLdf7MgSqteAPuvUoUC5MW6AaumlDiVj0Grl5NYrgC7nm2g9dbKZJURtNtAngWqSJoDOxXLvwyuNsat2JMKnpeLPpeZVNT5EhbKnaBJ+uOZLm/ZBhx9OwTovEudKfidYt1oAd+u6rTZ5CgUP3jwJLTSYDxy4NT9W9wZMxBcR6ev90k9crs4fL4ZTReGtW/EFLoJ/X8cRX0j5A4GV4aKy/lBWgUnqMgNZJZZLGB2FnkumzjqE+c20jr6BRij82opI3/1DcQO0dzlkaSDCUcZK/kS46hfyCtJpgCBmpVohSRarTZJJUvLqjXuj7O6VJOV5FYqTDqmuJkPNHUZWzikZxn51xyYAhzcU9PnEXdaWgNaoZiyYiYyOGuyDuwSnp8/rYwSnDwGS0Y4NS63xO04rEOUNpdMbqu0EJseISAH0bz8aWka7+kBopbG58FU3SyNfxYGqIx27nuCLgvRbsH/IZDF/WmrODZJMXaK5haQeX/N28SPTTt35VFCSjGnQBMPCplH417KQVrp2SWeQgpVfo2grrRykpx9RnhKO0HgP7hdJR2TqrZ1wiGDp6kUIYqr6xXdZOm1KVGN+21eu5dNw6ndFp0DoyskXHnu7qX0dlVlHf6PbdO4wzHnHD/psTBsQ== [email protected]"
54+
public_key = data.github_user.my_user.ssh_keys.0
4055
}
4156

4257
resource "hcloud_firewall" "firewall_kubernetes" {

0 commit comments

Comments
 (0)