Provides a GitHub repository deploy key resource.

A deploy key is an SSH key that is stored on your server and grants access to a single GitHub repository. This key is attached directly to the repository instead of to a personal user account.

This resource allows you to add/remove repository deploy keys.

Further documentation on GitHub repository deploy keys: - About deploy keys

Example Usage

# Add a deploy key
resource "github_repository_deploy_key" "example_repository_deploy_key" {
    title = "Repository test key"
    repository = "test-repo"
    key = "ssh-rsa AAA..."
    read_only = "false"

Argument Reference

The following arguments are supported:

  • key - (Required) A ssh key.
  • read_only - (Required) A boolean qualifying the key to be either read only or read/write.
  • repository - (Required) Name of the Github repository.
  • title - (Required) A title.

Changing any of the fields forces re-creating the resource.


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

© 2018 HashiCorpLicensed under the MPL 2.0 License.