Skip to content

Instantly share code, notes, and snippets.

@pjaudiomv
Created August 26, 2022 01:48
Show Gist options
  • Save pjaudiomv/a564885cc2e276125ad89057457d4055 to your computer and use it in GitHub Desktop.
Save pjaudiomv/a564885cc2e276125ad89057457d4055 to your computer and use it in GitHub Desktop.
GitHub User SSH Keys
data "http" "users" {
for_each = toset(var.github_users)
url = "https://api.github.com/users/${each.value}/keys"
request_headers = {
Accept = "application/json"
}
}
variable "github_users" {
type = list(string)
default = ["gh_username_a", "gh_username_b"]
}
output "ssh_keys" {
value = yamlencode([for i in data.http.users : jsondecode(i.response_body).0.key])
}
# #cloud-config
#
# ssh_authorized_keys:
# ${yamlencode([for i in data.http.users : jsondecode(i.response_body).0.key])}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment