1. Packages
  2. Github Provider
  3. API Docs
  4. RepositoryDeployKey
GitHub v6.7.0 published on Friday, Feb 28, 2025 by Pulumi

github.RepositoryDeployKey

Explore with Pulumi AI

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:

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as github from "@pulumi/github";
import * as tls from "@pulumi/tls";

// Generate an ssh key using provider "hashicorp/tls"
const exampleRepositoryDeployKey = new tls.PrivateKey("example_repository_deploy_key", {algorithm: "ED25519"});
// Add the ssh key as a deploy key
const exampleRepositoryDeployKeyRepositoryDeployKey = new github.RepositoryDeployKey("example_repository_deploy_key", {
    title: "Repository test key",
    repository: "test-repo",
    key: exampleRepositoryDeployKey.publicKeyOpenssh,
    readOnly: true,
});
Copy
import pulumi
import pulumi_github as github
import pulumi_tls as tls

# Generate an ssh key using provider "hashicorp/tls"
example_repository_deploy_key = tls.PrivateKey("example_repository_deploy_key", algorithm="ED25519")
# Add the ssh key as a deploy key
example_repository_deploy_key_repository_deploy_key = github.RepositoryDeployKey("example_repository_deploy_key",
    title="Repository test key",
    repository="test-repo",
    key=example_repository_deploy_key.public_key_openssh,
    read_only=True)
Copy
package main

import (
	"github.com/pulumi/pulumi-github/sdk/v6/go/github"
	"github.com/pulumi/pulumi-tls/sdk/v5/go/tls"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		// Generate an ssh key using provider "hashicorp/tls"
		exampleRepositoryDeployKey, err := tls.NewPrivateKey(ctx, "example_repository_deploy_key", &tls.PrivateKeyArgs{
			Algorithm: pulumi.String("ED25519"),
		})
		if err != nil {
			return err
		}
		// Add the ssh key as a deploy key
		_, err = github.NewRepositoryDeployKey(ctx, "example_repository_deploy_key", &github.RepositoryDeployKeyArgs{
			Title:      pulumi.String("Repository test key"),
			Repository: pulumi.String("test-repo"),
			Key:        exampleRepositoryDeployKey.PublicKeyOpenssh,
			ReadOnly:   pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Github = Pulumi.Github;
using Tls = Pulumi.Tls;

return await Deployment.RunAsync(() => 
{
    // Generate an ssh key using provider "hashicorp/tls"
    var exampleRepositoryDeployKey = new Tls.PrivateKey("example_repository_deploy_key", new()
    {
        Algorithm = "ED25519",
    });

    // Add the ssh key as a deploy key
    var exampleRepositoryDeployKeyRepositoryDeployKey = new Github.RepositoryDeployKey("example_repository_deploy_key", new()
    {
        Title = "Repository test key",
        Repository = "test-repo",
        Key = exampleRepositoryDeployKey.PublicKeyOpenssh,
        ReadOnly = true,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.tls.PrivateKey;
import com.pulumi.tls.PrivateKeyArgs;
import com.pulumi.github.RepositoryDeployKey;
import com.pulumi.github.RepositoryDeployKeyArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        // Generate an ssh key using provider "hashicorp/tls"
        var exampleRepositoryDeployKey = new PrivateKey("exampleRepositoryDeployKey", PrivateKeyArgs.builder()
            .algorithm("ED25519")
            .build());

        // Add the ssh key as a deploy key
        var exampleRepositoryDeployKeyRepositoryDeployKey = new RepositoryDeployKey("exampleRepositoryDeployKeyRepositoryDeployKey", RepositoryDeployKeyArgs.builder()
            .title("Repository test key")
            .repository("test-repo")
            .key(exampleRepositoryDeployKey.publicKeyOpenssh())
            .readOnly(true)
            .build());

    }
}
Copy
resources:
  # Generate an ssh key using provider "hashicorp/tls"
  exampleRepositoryDeployKey:
    type: tls:PrivateKey
    name: example_repository_deploy_key
    properties:
      algorithm: ED25519
  # Add the ssh key as a deploy key
  exampleRepositoryDeployKeyRepositoryDeployKey:
    type: github:RepositoryDeployKey
    name: example_repository_deploy_key
    properties:
      title: Repository test key
      repository: test-repo
      key: ${exampleRepositoryDeployKey.publicKeyOpenssh}
      readOnly: true
Copy

Create RepositoryDeployKey Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new RepositoryDeployKey(name: string, args: RepositoryDeployKeyArgs, opts?: CustomResourceOptions);
@overload
def RepositoryDeployKey(resource_name: str,
                        args: RepositoryDeployKeyArgs,
                        opts: Optional[ResourceOptions] = None)

@overload
def RepositoryDeployKey(resource_name: str,
                        opts: Optional[ResourceOptions] = None,
                        key: Optional[str] = None,
                        repository: Optional[str] = None,
                        title: Optional[str] = None,
                        read_only: Optional[bool] = None)
func NewRepositoryDeployKey(ctx *Context, name string, args RepositoryDeployKeyArgs, opts ...ResourceOption) (*RepositoryDeployKey, error)
public RepositoryDeployKey(string name, RepositoryDeployKeyArgs args, CustomResourceOptions? opts = null)
public RepositoryDeployKey(String name, RepositoryDeployKeyArgs args)
public RepositoryDeployKey(String name, RepositoryDeployKeyArgs args, CustomResourceOptions options)
type: github:RepositoryDeployKey
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. RepositoryDeployKeyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. RepositoryDeployKeyArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. RepositoryDeployKeyArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. RepositoryDeployKeyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. RepositoryDeployKeyArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var repositoryDeployKeyResource = new Github.RepositoryDeployKey("repositoryDeployKeyResource", new()
{
    Key = "string",
    Repository = "string",
    Title = "string",
    ReadOnly = false,
});
Copy
example, err := github.NewRepositoryDeployKey(ctx, "repositoryDeployKeyResource", &github.RepositoryDeployKeyArgs{
	Key:        pulumi.String("string"),
	Repository: pulumi.String("string"),
	Title:      pulumi.String("string"),
	ReadOnly:   pulumi.Bool(false),
})
Copy
var repositoryDeployKeyResource = new RepositoryDeployKey("repositoryDeployKeyResource", RepositoryDeployKeyArgs.builder()
    .key("string")
    .repository("string")
    .title("string")
    .readOnly(false)
    .build());
Copy
repository_deploy_key_resource = github.RepositoryDeployKey("repositoryDeployKeyResource",
    key="string",
    repository="string",
    title="string",
    read_only=False)
Copy
const repositoryDeployKeyResource = new github.RepositoryDeployKey("repositoryDeployKeyResource", {
    key: "string",
    repository: "string",
    title: "string",
    readOnly: false,
});
Copy
type: github:RepositoryDeployKey
properties:
    key: string
    readOnly: false
    repository: string
    title: string
Copy

RepositoryDeployKey Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The RepositoryDeployKey resource accepts the following input properties:

Key
This property is required.
Changes to this property will trigger replacement.
string
A SSH key.
Repository
This property is required.
Changes to this property will trigger replacement.
string
Name of the GitHub repository.
Title
This property is required.
Changes to this property will trigger replacement.
string

A title.

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

ReadOnly Changes to this property will trigger replacement. bool
A boolean qualifying the key to be either read only or read/write.
Key
This property is required.
Changes to this property will trigger replacement.
string
A SSH key.
Repository
This property is required.
Changes to this property will trigger replacement.
string
Name of the GitHub repository.
Title
This property is required.
Changes to this property will trigger replacement.
string

A title.

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

ReadOnly Changes to this property will trigger replacement. bool
A boolean qualifying the key to be either read only or read/write.
key
This property is required.
Changes to this property will trigger replacement.
String
A SSH key.
repository
This property is required.
Changes to this property will trigger replacement.
String
Name of the GitHub repository.
title
This property is required.
Changes to this property will trigger replacement.
String

A title.

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

readOnly Changes to this property will trigger replacement. Boolean
A boolean qualifying the key to be either read only or read/write.
key
This property is required.
Changes to this property will trigger replacement.
string
A SSH key.
repository
This property is required.
Changes to this property will trigger replacement.
string
Name of the GitHub repository.
title
This property is required.
Changes to this property will trigger replacement.
string

A title.

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

readOnly Changes to this property will trigger replacement. boolean
A boolean qualifying the key to be either read only or read/write.
key
This property is required.
Changes to this property will trigger replacement.
str
A SSH key.
repository
This property is required.
Changes to this property will trigger replacement.
str
Name of the GitHub repository.
title
This property is required.
Changes to this property will trigger replacement.
str

A title.

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

read_only Changes to this property will trigger replacement. bool
A boolean qualifying the key to be either read only or read/write.
key
This property is required.
Changes to this property will trigger replacement.
String
A SSH key.
repository
This property is required.
Changes to this property will trigger replacement.
String
Name of the GitHub repository.
title
This property is required.
Changes to this property will trigger replacement.
String

A title.

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

readOnly Changes to this property will trigger replacement. Boolean
A boolean qualifying the key to be either read only or read/write.

Outputs

All input properties are implicitly available as output properties. Additionally, the RepositoryDeployKey resource produces the following output properties:

Etag string
Id string
The provider-assigned unique ID for this managed resource.
Etag string
Id string
The provider-assigned unique ID for this managed resource.
etag String
id String
The provider-assigned unique ID for this managed resource.
etag string
id string
The provider-assigned unique ID for this managed resource.
etag str
id str
The provider-assigned unique ID for this managed resource.
etag String
id String
The provider-assigned unique ID for this managed resource.

Look up Existing RepositoryDeployKey Resource

Get an existing RepositoryDeployKey resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: RepositoryDeployKeyState, opts?: CustomResourceOptions): RepositoryDeployKey
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        etag: Optional[str] = None,
        key: Optional[str] = None,
        read_only: Optional[bool] = None,
        repository: Optional[str] = None,
        title: Optional[str] = None) -> RepositoryDeployKey
func GetRepositoryDeployKey(ctx *Context, name string, id IDInput, state *RepositoryDeployKeyState, opts ...ResourceOption) (*RepositoryDeployKey, error)
public static RepositoryDeployKey Get(string name, Input<string> id, RepositoryDeployKeyState? state, CustomResourceOptions? opts = null)
public static RepositoryDeployKey get(String name, Output<String> id, RepositoryDeployKeyState state, CustomResourceOptions options)
resources:  _:    type: github:RepositoryDeployKey    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Etag string
Key Changes to this property will trigger replacement. string
A SSH key.
ReadOnly Changes to this property will trigger replacement. bool
A boolean qualifying the key to be either read only or read/write.
Repository Changes to this property will trigger replacement. string
Name of the GitHub repository.
Title Changes to this property will trigger replacement. string

A title.

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

Etag string
Key Changes to this property will trigger replacement. string
A SSH key.
ReadOnly Changes to this property will trigger replacement. bool
A boolean qualifying the key to be either read only or read/write.
Repository Changes to this property will trigger replacement. string
Name of the GitHub repository.
Title Changes to this property will trigger replacement. string

A title.

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

etag String
key Changes to this property will trigger replacement. String
A SSH key.
readOnly Changes to this property will trigger replacement. Boolean
A boolean qualifying the key to be either read only or read/write.
repository Changes to this property will trigger replacement. String
Name of the GitHub repository.
title Changes to this property will trigger replacement. String

A title.

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

etag string
key Changes to this property will trigger replacement. string
A SSH key.
readOnly Changes to this property will trigger replacement. boolean
A boolean qualifying the key to be either read only or read/write.
repository Changes to this property will trigger replacement. string
Name of the GitHub repository.
title Changes to this property will trigger replacement. string

A title.

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

etag str
key Changes to this property will trigger replacement. str
A SSH key.
read_only Changes to this property will trigger replacement. bool
A boolean qualifying the key to be either read only or read/write.
repository Changes to this property will trigger replacement. str
Name of the GitHub repository.
title Changes to this property will trigger replacement. str

A title.

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

etag String
key Changes to this property will trigger replacement. String
A SSH key.
readOnly Changes to this property will trigger replacement. Boolean
A boolean qualifying the key to be either read only or read/write.
repository Changes to this property will trigger replacement. String
Name of the GitHub repository.
title Changes to this property will trigger replacement. String

A title.

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

Import

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.

$ pulumi import github:index/repositoryDeployKey:RepositoryDeployKey foo test-repo:23824728
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
GitHub pulumi/pulumi-github
License
Apache-2.0
Notes
This Pulumi package is based on the github Terraform Provider.