Skip to content
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

Merged
merged 12 commits into from
Dec 15, 2020

Conversation

AliAllomani
Copy link
Contributor

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

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Copy link
Contributor

@yupwei68 yupwei68 left a 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.

README.md Outdated Show resolved Hide resolved
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
Copy link
Contributor

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?

@@ -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="
Copy link
Contributor

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.

variables.tf Outdated Show resolved Hide resolved
@AliAllomani
Copy link
Contributor Author

@yupwei68 thanks for your review, let me know if it looks better now.

Copy link
Contributor

@yupwei68 yupwei68 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@yupwei68 yupwei68 merged commit 1c6986b into Azure:master Dec 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Need the ability to reuse ssh key pair in Azure subscription
2 participants