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,
});
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)
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
})
}
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,
});
});
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());
}
}
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
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 string
- The unique name of the resource.
- args RepositoryDeployKeyArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args 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 string
- The unique name of the resource.
- args RepositoryDeployKeyArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args RepositoryDeployKeyArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args 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,
});
example, err := github.NewRepositoryDeployKey(ctx, "repositoryDeployKeyResource", &github.RepositoryDeployKeyArgs{
Key: pulumi.String("string"),
Repository: pulumi.String("string"),
Title: pulumi.String("string"),
ReadOnly: pulumi.Bool(false),
})
var repositoryDeployKeyResource = new RepositoryDeployKey("repositoryDeployKeyResource", RepositoryDeployKeyArgs.builder()
.key("string")
.repository("string")
.title("string")
.readOnly(false)
.build());
repository_deploy_key_resource = github.RepositoryDeployKey("repositoryDeployKeyResource",
key="string",
repository="string",
title="string",
read_only=False)
const repositoryDeployKeyResource = new github.RepositoryDeployKey("repositoryDeployKeyResource", {
key: "string",
repository: "string",
title: "string",
readOnly: false,
});
type: github:RepositoryDeployKey
properties:
key: string
readOnly: false
repository: string
title: string
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 string
- A SSH key.
- Repository string
- Name of the GitHub repository.
- Title string
A title.
Changing any of the fields forces re-creating the resource.
- Read
Only bool - A boolean qualifying the key to be either read only or read/write.
- Key string
- A SSH key.
- Repository string
- Name of the GitHub repository.
- Title string
A title.
Changing any of the fields forces re-creating the resource.
- Read
Only bool - A boolean qualifying the key to be either read only or read/write.
- key String
- A SSH key.
- repository String
- Name of the GitHub repository.
- title String
A title.
Changing any of the fields forces re-creating the resource.
- read
Only Boolean - A boolean qualifying the key to be either read only or read/write.
- key string
- A SSH key.
- repository string
- Name of the GitHub repository.
- title string
A title.
Changing any of the fields forces re-creating the resource.
- read
Only boolean - A boolean qualifying the key to be either read only or read/write.
- key str
- A SSH key.
- repository str
- Name of the GitHub repository.
- title str
A title.
Changing any of the fields forces re-creating the resource.
- read_
only bool - A boolean qualifying the key to be either read only or read/write.
- key String
- A SSH key.
- repository String
- Name of the GitHub repository.
- title String
A title.
Changing any of the fields forces re-creating the resource.
- read
Only 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:
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)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- 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.
- Etag string
- Key string
- A SSH key.
- Read
Only bool - A boolean qualifying the key to be either read only or read/write.
- Repository string
- Name of the GitHub repository.
- Title string
A title.
Changing any of the fields forces re-creating the resource.
- Etag string
- Key string
- A SSH key.
- Read
Only bool - A boolean qualifying the key to be either read only or read/write.
- Repository string
- Name of the GitHub repository.
- Title string
A title.
Changing any of the fields forces re-creating the resource.
- etag String
- key String
- A SSH key.
- read
Only Boolean - A boolean qualifying the key to be either read only or read/write.
- repository String
- Name of the GitHub repository.
- title String
A title.
Changing any of the fields forces re-creating the resource.
- etag string
- key string
- A SSH key.
- read
Only boolean - A boolean qualifying the key to be either read only or read/write.
- repository string
- Name of the GitHub repository.
- title string
A title.
Changing any of the fields forces re-creating the resource.
- etag str
- key str
- A SSH key.
- read_
only bool - A boolean qualifying the key to be either read only or read/write.
- repository str
- Name of the GitHub repository.
- title str
A title.
Changing any of the fields forces re-creating the resource.
- etag String
- key String
- A SSH key.
- read
Only Boolean - A boolean qualifying the key to be either read only or read/write.
- repository String
- Name of the GitHub repository.
- title 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
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.