integrations / terraform-provider-github

Terraform GitHub provider

Home Page:https://www.terraform.io/docs/providers/github/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[FEAT]: data.github_user.ssh_keys - Allow returning the key ID as well

fkonradmain opened this issue · comments

Describe the need

When this provider is used to retrieve the public ssh keys of a user, it only provides a list of ssh keys, as you would get when calling:

curl -L \
  -H "Accept: text/plain" \
  https://github.com/<username>.keys

This list only cotains the ssh key list, but it does not deliver any ids. Although it seems to be sorted by key id.

The result looks like this:

[
  "ssh-rsa AAAASsdafasdfsadlewwelrwerwerwlerkwjerlkwerlw...",
  "ssh-ed25519 AAAASsdafasdfsdfsdfsdfeefefwsc322323asddfsadl...",
]

Yet, when calling the api, we can also retrieve the SSH Key id. Api Documentation Link

curl -L \
  -H "Accept: application/vnd.github+json" \
  # -H "Authorization: Bearer <YOUR-TOKEN>" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/users/USERNAME/keys

My feature request is the ability to retrieve this key id through the terraform provider as well. This would provide the possiblity to safely iterate through the list of ssh keys and it would also provide the chance to address each key individually.

This would make the result look like this:

[
  {
    id = 11111111
    key = "ssh-rsa AAAASsdafasdfsadlewwelrwerwerwlerkwjerlkwerlw...",
  },
  {
    id = 11112222
    key = "ssh-ed25519 AAAASsdafasdfsdfsdfsdfeefefwsc322323asddfsadl...",
  }
]

This would also change the data type of the result from list(string) to list(map(string)).

Since this is a breaking change (unless terraform introduces a map default type that is returned, when addressing a map directly), it should be realized through an additional api call.

Thank you very much.

SDK Version

6.2.0

API Version

2022-11-28

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct