-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support raw value for ssh keys in addition to paths #159
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution 🚀 ! This PR looks almost good to me, except some comments left.
main.tf
Outdated
@@ -105,7 +105,7 @@ resource "azurerm_virtual_machine" "vm-linux" { | |||
for_each = var.enable_ssh_key ? local.ssh_keys : [] | |||
content { | |||
path = "/home/${var.admin_username}/.ssh/authorized_keys" | |||
key_data = file(ssh_keys.value) | |||
key_data = lower(substr(ssh_keys.value,-4,4)) == ".pub" ? file(ssh_keys.value) : ssh_keys.value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using an old variable to represent both directory and value, I'd like to suggest add a new variable ssh_key_value
?
test/fixture/main.tf
Outdated
@@ -85,6 +85,7 @@ module "debianservers" { | |||
vnet_subnet_id = azurerm_subnet.subnet2.id | |||
allocation_method = "Static" | |||
enable_ssh_key = true | |||
ssh_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC8GIRF1Snlg9NKCmM74RHXqRGMXyui088+ntQqkQkFIL/BrlgP3CzOgHQmJ+3f0Up/+9UY9vX7AmT7WxVTyqBHT/Aes3VmU3wLO5/MMV/HRrT4z2QV/80futhxjk2unNdWGvbFcR6Y3I44EJFmr8GMbyXRtr0ibuv8BlTYx/K6AXSJ3V+kBqXMOF1QRvVoX9fJKPKjMsebe0cB1IYlm9KLqtciMy+aFOEsSNfrw5cNVsQfK3BgOUKAHsLfBiR7imA2ca+hh005GEtcVJvpvFzcM+bZggUpdqQwIzk1Kv/tROiJiGS0NnyzoxIZYeM3z/mQ5qnglp+174XGCG66EAnVdf5kbaI0Iu7FpAmVhJ92N+MNKoP6vT8cMkYYZf3RaiMMnzjswK/VLbb5ks6Qe9qEPXW1IBtkaaF7+0PCWbPr86I0G2bOa2tFyOHm046Z9sRlkaOO95hmer6Y6MUbMpfeprmjR87u6MVOPglnARfV3UI9i6wOUhVVIi6Wb424HWU=" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here please add a new linux module instance to test ssh_key_value
. Because we have ubuntuservers
to test enable_ssh_key
is false, "debian" to test ssh_key
is directory, and we need one more to test ssh_key_value
.
@yupwei68 thanks for your review, let me know if it looks better now. |
change name to `ssh_key_values`
format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Fixes #153
Adding the ability of defining ssh keys as raw value either to pass it directly as string to the module or refer it from another data source