Skip to content

Commit

Permalink
main.tf: Add script to delete generated ssh keys
Browse files Browse the repository at this point in the history
  • Loading branch information
MiguelNdeCarvalho committed Jul 8, 2024
1 parent f8fae39 commit d39f5cf
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ resource "kubernetes_config_map" "main" {
data = {
"authorized_keys" = var.ssh_keys
"motd" = "Welcome to ${var.motd_name}.\n"
"delete-generated-ssh-keys" = <<EOT
#!/bin/bash
echo "**** remove not needed ecdsa and ed25519 keys ****"
rm /config/ssh_host_keys/ssh_host_ecdsa*
rm /config/ssh_host_keys/ssh_host_ed25519*
EOT
}
}

Expand Down Expand Up @@ -77,6 +83,19 @@ resource "kubernetes_deployment" "main" {
}
}

volume {
name = "delete-generated-ssh-keys"

config_map {
name = local.resource_name

items {
key = "delete-generated-ssh-keys"
path = "delete-generated-ssh-keys"
}
}
}

volume {
name = "ssh-host-rsa-key"

Expand Down Expand Up @@ -133,6 +152,13 @@ resource "kubernetes_deployment" "main" {
sub_path = "authorized_keys"
}

volume_mount {
name = "delete-generated-ssh-keys"
mount_path = "/custom-cont-init.d/delete-generated-ssh-keys"
sub_path = "delete-generated-ssh-keys"
read_only = true
}

volume_mount {
name = "ssh-host-rsa-key"
mount_path = "/config/ssh_host_keys/ssh_host_rsa_key"
Expand Down

0 comments on commit d39f5cf

Please sign in to comment.