Closed calorbeer closed 3 years ago
In order to keep backwards compatibility I'd like to propose a different solution: ssh_authorized_keys is kept however metadata block is changed to
resource "oci_core_instance" "this" {
...
metadata = {
ssh_authorized_keys = (var.ssh_public_key != "" ? var.ssh_public_key :
(var.ssh_public_key_path != "" ? file(var.ssh_public_key_path) :
(var.ssh_authorized_keys != "" ? file(var.ssh_authorized_keys) : "")))
...
}
}
@calorbeer version 2.2.0-RC1 was released. It includes the change you suggested on ssh public keys. Give it a try when you can and let me know if that works for you :-)
@kral2 It looks like there's an issue that ssh variables defaults to null. If var.ssh_public_key is set ssh ssh_authorized_keys is set correctly however if it's null the condition is also true and as a result it is set to null. The file statements are never reached. To avoid this the variables either need to default to "" or the conditions have to test for != null and "".
Thank you for this feedback @calorbeer I have opened #70, let's continue the discussion there.
Community Note
Description
Both oracle-terraform-modules bastian and operator modules support ssh public keys to be passed in as strings and as files. terraform-oci-compute-instance only supports files which makes it challenging to write terraform code that automatically assigns ssh keys. Adding support for ssh_public_key would align all three modules in terms of ssh key usability.
New or Affected Resource(s)
oci_core_instance
Potential Terraform Configuration
Add the following two variables:
Replace
by
References