Skip to content

Commit 7956f10

Browse files
committed
3
1 parent 5e43a50 commit 7956f10

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

terraform/gcp/main.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
resource "tls_private_key" "ssh_key" {
2+
algorithm = "RSA"
3+
rsa_bits = 4096
4+
}
5+
6+
# public_key = tls_private_key.ssh_key.public_key_openssh
7+
8+
19
resource "google_compute_disk" "dle_zfs_disk" {
210
name = "dle-zfs-disk${count.index}"
311
count = 3
@@ -24,6 +32,16 @@ resource "google_compute_instance" "vm_instance" {
2432
access_config {
2533
}
2634
}
35+
36+
metadata = {
37+
ssh-keys = "ubuntu:${tls_private_key.ssh_key.public_key_openssh}"
38+
}
39+
provisioner "local-exec" { # save private key locally
40+
command = "echo '${tls_private_key.ssh_key.private_key_pem}' > ./dle.pem"
41+
}
42+
provisioner "local-exec" {
43+
command = "chmod 600 ./dle.pem"
44+
}
2745
}
2846

2947
resource "google_compute_attached_disk" "dle_attached_zfs_disk" {

0 commit comments

Comments
 (0)