Answers: <p>OK, I found it..</p>
  <pre><code>gh api https://api.github.com/repos/&lt;OWNER&gt;/&lt;REPO&gt;/keys | jq .[].id
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2022-12-08T11:03:58.487Z
Answers: 2022-12-08T11:03:58.487Z
Answers: sobi3ch
Body: <p>I've added GitHub Deploy key manually. Now I would likt to <code>import</code> it to my state. But when I look into <a href="https://registry.terraform.io/providers/integrations/github/latest/docs/resources/repository_deploy_key#import" rel="nofollow noreferrer">github_repository_deploy_key resource docs</a> I can read</p>
  <blockquote>
  <p><em>&quot;Repository deploy keys can be imported using a colon-separated pair of repository name and GitHub's key id. The latter can be obtained by GitHub's SDKs and API.&quot;</em></p>
  <p><em><code>$ terraform import github_repository_deploy_key.foo test-repo:23824728</code></em></p>
  </blockquote>
  <p>I was looking for this GitHub's key id for a long time but without a luck. If I go to <a href="https://github.com/%5C" rel="nofollow noreferrer">https://github.com/\</a>/&lt;REPO&gt;/settings/keys I cannot see any ID (numerical) in my key information.</p>
  <p>I've try to use <code>SHA256:</code> bit from deploy key information, but it end's up with the following error:</p>
  <blockquote>
  <p>Error: Unexpected ID format (&quot;ddf62fc...&quot;), expected numerical ID. strconv.ParseInt: parsing &quot;ddf62fc...&quot;: invalid syntax</p>
  </blockquote>
  <p>How can I find my GitHub's (deploy) key ID?</p>
  
Tags: <terraform><github>
Title: Where can I find GitHub's key id to import key for github_repository_deploy_key resource?
UserDisplayName: sobi3ch
ThreadText: # Where can I find GitHub's key id to import key for github_repository_deploy_key resource?
  
  (Asked by: username_0 on 2022-12-08)
  
  I've added GitHub Deploy key manually. Now I would likt to `import` it to my state. But when I look into [github\_repository\_deploy\_key resource docs](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/repository_deploy_key#import) I can read
  
  > *"Repository deploy keys can be imported using a colon-separated pair of repository name and GitHub's key id. The latter can be obtained by GitHub's SDKs and API."*
  >
  > *`$ terraform import github_repository_deploy_key.foo test-repo:23824728`*
  
  I was looking for this GitHub's key id for a long time but without a luck. If I go to [https://github.com/\](https://github.com/%5C)/<REPO>/settings/keys I cannot see any ID (numerical) in my key information.
  
  I've try to use `SHA256:` bit from deploy key information, but it end's up with the following error:
  
  > Error: Unexpected ID format ("ddf62fc..."), expected numerical ID. strconv.ParseInt: parsing "ddf62fc...": invalid syntax
  
  How can I find my GitHub's (deploy) key ID?
  
  **Tags:** terraform, github
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2022-12-08. Score: 1
  
  OK, I found it..
  
  ```
  gh api https://api.github.com/repos/<OWNER>/<REPO>/keys | jq .[].id
  
  ```
  
  
  ---
  
  