File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change
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
+
1
9
resource "google_compute_disk" "dle_zfs_disk" {
2
10
name = " dle-zfs-disk${ count . index } "
3
11
count = 3
@@ -24,6 +32,16 @@ resource "google_compute_instance" "vm_instance" {
24
32
access_config {
25
33
}
26
34
}
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
+ }
27
45
}
28
46
29
47
resource "google_compute_attached_disk" "dle_attached_zfs_disk" {
You can’t perform that action at this time.
0 commit comments