Files
threshold/enos/modules/ssh_keypair/main.tf
T
Michael LiandTony f735676657 chore(e2e): Remove aws_ssh_keypair requirement (#6583)
* chore(e2e): Remove ssh key pair variable requirement

* CR

---------

Co-authored-by: Tony <wongtonyb@gmail.com>
2026-04-16 13:42:08 -04:00

39 lines
991 B
Terraform

# Copyright IBM Corp. 2024, 2026
# SPDX-License-Identifier: BUSL-1.1
terraform {
required_providers {
tls = {
source = "hashicorp/tls"
}
local = {
source = "hashicorp/local"
}
}
}
variable "local_key_path" {
type = string
description = "Path to a local key. If provided, this key will be used instead of generating a new one."
default = null
}
resource "random_pet" "default" {}
resource "tls_private_key" "ssh" {
count = var.local_key_path == null ? 1 : 0
algorithm = "RSA"
rsa_bits = 4096
}
resource "local_sensitive_file" "private_key" {
count = var.local_key_path == null ? 1 : 0
content = tls_private_key.ssh[0].private_key_pem
filename = "${path.root}/.terraform/tmp/ssh-key-enos-${random_pet.default.id}"
file_permission = "0400"
}
output "private_key_path" {
value = var.local_key_path != null ? abspath(var.local_key_path) : abspath(local_sensitive_file.private_key[0].filename)
}