Added SSH key generation feature to AWS and OCI

This commit is contained in:
Will Smith 2024-04-25 21:01:21 +00:00
parent 19816784af
commit 25f0dd183b
No known key found for this signature in database
GPG key ID: A4162186EBD5C0FF
32 changed files with 277 additions and 17 deletions

View file

@ -34,3 +34,9 @@ module "kasm" {
admin_password = var.admin_password
user_password = var.user_password
}
output "ssh_key_info" {
description = "SSH Keys to use with Kasm Deployment"
value = module.standard.ssh_key_info
sensitive = true
}

View file

@ -24,7 +24,7 @@ resource "oci_core_instance" "kasm_instance" {
}
metadata = {
ssh_authorized_keys = var.ssh_authorized_keys
ssh_authorized_keys = var.ssh_authorized_keys == "" ? tls_private_key.ssh_key[0].public_key_openssh : var.ssh_authorized_keys
user_data = base64encode(templatefile("${path.module}/userdata/bootstrap.sh",
{
kasm_build_url = var.kasm_build_url

View file

@ -0,0 +1,16 @@
resource "tls_private_key" "ssh_key" {
count = var.ssh_authorized_keys == "" ? 1 : 0
algorithm = "ED25519"
}
output "ssh_key_info" {
description = "SSH Keys for use with Kasm Deployment"
value = <<-SSHKEYS
SSH Keys:
%{if var.ssh_authorized_keys == ""}
Public Key: ${tls_private_key.ssh_key[0].public_key_openssh}
Private Key:
${tls_private_key.ssh_key[0].private_key_openssh}
%{endif}
SSHKEYS
}

View file

@ -44,3 +44,9 @@ module "kasm" {
database_password = var.database_password
service_registration_token = var.service_registration_token
}
output "ssh_key_info" {
description = "SSH Keys to use with Kasm Deployment"
value = module.standard.ssh_key_info
sensitive = true
}

View file

@ -27,7 +27,7 @@ resource "oci_core_instance" "agent" {
metadata = {
ssh_authorized_keys = var.ssh_authorized_keys
ssh_authorized_keys = var.ssh_authorized_keys == "" ? tls_private_key.ssh_key[0].public_key_openssh : var.ssh_authorized_keys
user_data = base64encode(templatefile("${path.module}/userdata/agent_bootstrap.sh",
{
kasm_build_url = var.kasm_build_url

View file

@ -25,6 +25,6 @@ resource "oci_core_instance" "bastion" {
}
metadata = {
ssh_authorized_keys = var.ssh_authorized_keys
ssh_authorized_keys = var.ssh_authorized_keys == "" ? tls_private_key.ssh_key[0].public_key_openssh : var.ssh_authorized_keys
}
}

View file

@ -27,7 +27,7 @@ resource "oci_core_instance" "cpx" {
metadata = {
ssh_authorized_keys = var.ssh_authorized_keys
ssh_authorized_keys = var.ssh_authorized_keys == "" ? tls_private_key.ssh_key[0].public_key_openssh : var.ssh_authorized_keys
user_data = base64encode(templatefile("${path.module}/userdata/cpx_bootstrap.sh",
{
kasm_build_url = var.kasm_build_url

View file

@ -24,7 +24,7 @@ resource "oci_core_instance" "db" {
}
metadata = {
ssh_authorized_keys = var.ssh_authorized_keys
ssh_authorized_keys = var.ssh_authorized_keys == "" ? tls_private_key.ssh_key[0].public_key_openssh : var.ssh_authorized_keys
user_data = base64encode(templatefile("${path.module}/userdata/db_bootstrap.sh",
{
kasm_build_url = var.kasm_build_url

View file

@ -0,0 +1,16 @@
resource "tls_private_key" "ssh_key" {
count = var.ssh_authorized_keys == "" ? 1 : 0
algorithm = "ED25519"
}
output "ssh_key_info" {
description = "SSH Keys for use with Kasm Deployment"
value = <<-SSHKEYS
SSH Keys:
%{if var.ssh_authorized_keys == ""}
Public Key: ${tls_private_key.ssh_key[0].public_key_openssh}
Private Key:
${tls_private_key.ssh_key[0].private_key_openssh}
%{endif}
SSHKEYS
}

View file

@ -26,7 +26,7 @@ resource "oci_core_instance" "webapp" {
}
metadata = {
ssh_authorized_keys = var.ssh_authorized_keys
ssh_authorized_keys = var.ssh_authorized_keys == "" ? tls_private_key.ssh_key[0].public_key_openssh : var.ssh_authorized_keys
user_data = base64encode(templatefile("${path.module}/userdata/webapp_bootstrap.sh",
{
kasm_build_url = var.kasm_build_url