-
Notifications
You must be signed in to change notification settings - Fork 801
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
User Story 125263 #238
User Story 125263 #238
Changes from all commits
e605197
bcd7557
05c5cc4
369fed9
2e3a878
490c01d
16950b8
deb3ed5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
resource "random_pet" "ssh_key_name" { | ||
prefix = "ssh" | ||
separator = "" | ||
} | ||
|
||
resource "azapi_resource_action" "ssh_public_key_gen" { | ||
type = "Microsoft.Compute/sshPublicKeys@2022-11-01" | ||
resource_id = azapi_resource.ssh_public_key.id | ||
action = "generateKeyPair" | ||
method = "POST" | ||
|
||
response_export_values = ["publicKey", "privateKey"] | ||
} | ||
|
||
resource "azapi_resource" "ssh_public_key" { | ||
type = "Microsoft.Compute/sshPublicKeys@2022-11-01" | ||
name = random_pet.ssh_key_name.id | ||
location = azurerm_resource_group.rg.location | ||
parent_id = azurerm_resource_group.rg.id | ||
} | ||
|
||
output "key_data" { | ||
value = jsondecode(azapi_resource_action.ssh_public_key_gen.output).publicKey | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,10 @@ variable "resource_group_name_prefix" { | |
type = string | ||
default = "rg" | ||
description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription." | ||
} | ||
|
||
variable "username" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we've set default value for this variable I think we can set |
||
type = string | ||
description = "The username for the local account that will be created on the new VM." | ||
default = "azureadmin" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default value is different than the corresponding default value in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
} |
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.
Could we move this
output
block tooutputs.tf
file?And I've tried this output, it's value is empty. If we want to export the generated public key data as output, we can use the following code snippet:
Since public key data is not a secret and meant to be shared, I just removed
sensitive = true
.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.
Right now, the
ssh.tf
file is fully encapsulated, meaning that I can drop it into any configuration and it works. I want to keep this pattern instead of having functionality spread across multiple files.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.
That makes sense to me.
But I think we still need to ensure that
value = azapi_resource.ssh_public_key.body
could output the public key, and I still think we could remove thissensitive = true
because the public key is meant to be shared.