1. Packages
  2. GitHub
  3. API Docs
  4. RepositoryDeployKey
GitHub v6.1.0 published on Monday, Mar 11, 2024 by Pulumi

github.RepositoryDeployKey

Explore with Pulumi AI

github logo
GitHub v6.1.0 published on Monday, Mar 11, 2024 by Pulumi

    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 exampleRepositoryDeployKeyPrivateKey = new tls.PrivateKey("exampleRepositoryDeployKeyPrivateKey", {algorithm: "ED25519"});
    // Add the ssh key as a deploy key
    const exampleRepositoryDeployKeyRepositoryDeployKey = new github.RepositoryDeployKey("exampleRepositoryDeployKeyRepositoryDeployKey", {
        title: "Repository test key",
        repository: "test-repo",
        key: exampleRepositoryDeployKeyPrivateKey.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_private_key = tls.PrivateKey("exampleRepositoryDeployKeyPrivateKey", algorithm="ED25519")
    # Add the ssh key as a deploy key
    example_repository_deploy_key_repository_deploy_key = github.RepositoryDeployKey("exampleRepositoryDeployKeyRepositoryDeployKey",
        title="Repository test key",
        repository="test-repo",
        key=example_repository_deploy_key_private_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"
    		exampleRepositoryDeployKeyPrivateKey, err := tls.NewPrivateKey(ctx, "exampleRepositoryDeployKeyPrivateKey", &tls.PrivateKeyArgs{
    			Algorithm: pulumi.String("ED25519"),
    		})
    		if err != nil {
    			return err
    		}
    		// Add the ssh key as a deploy key
    		_, err = github.NewRepositoryDeployKey(ctx, "exampleRepositoryDeployKeyRepositoryDeployKey", &github.RepositoryDeployKeyArgs{
    			Title:      pulumi.String("Repository test key"),
    			Repository: pulumi.String("test-repo"),
    			Key:        exampleRepositoryDeployKeyPrivateKey.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 exampleRepositoryDeployKeyPrivateKey = new Tls.PrivateKey("exampleRepositoryDeployKeyPrivateKey", new()
        {
            Algorithm = "ED25519",
        });
    
        // Add the ssh key as a deploy key
        var exampleRepositoryDeployKeyRepositoryDeployKey = new Github.RepositoryDeployKey("exampleRepositoryDeployKeyRepositoryDeployKey", new()
        {
            Title = "Repository test key",
            Repository = "test-repo",
            Key = exampleRepositoryDeployKeyPrivateKey.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) {
            var exampleRepositoryDeployKeyPrivateKey = new PrivateKey("exampleRepositoryDeployKeyPrivateKey", PrivateKeyArgs.builder()        
                .algorithm("ED25519")
                .build());
    
            var exampleRepositoryDeployKeyRepositoryDeployKey = new RepositoryDeployKey("exampleRepositoryDeployKeyRepositoryDeployKey", RepositoryDeployKeyArgs.builder()        
                .title("Repository test key")
                .repository("test-repo")
                .key(exampleRepositoryDeployKeyPrivateKey.publicKeyOpenssh())
                .readOnly(true)
                .build());
    
        }
    }
    
    resources:
      # Generate an ssh key using provider "hashicorp/tls"
      exampleRepositoryDeployKeyPrivateKey:
        type: tls:PrivateKey
        properties:
          algorithm: ED25519
      # Add the ssh key as a deploy key
      exampleRepositoryDeployKeyRepositoryDeployKey:
        type: github:RepositoryDeployKey
        properties:
          title: Repository test key
          repository: test-repo
          key: ${exampleRepositoryDeployKeyPrivateKey.publicKeyOpenssh}
          readOnly: true
    

    Create RepositoryDeployKey Resource

    new RepositoryDeployKey(name: string, args: RepositoryDeployKeyArgs, opts?: CustomResourceOptions);
    @overload
    def RepositoryDeployKey(resource_name: str,
                            opts: Optional[ResourceOptions] = None,
                            key: Optional[str] = None,
                            read_only: Optional[bool] = None,
                            repository: Optional[str] = None,
                            title: Optional[str] = None)
    @overload
    def RepositoryDeployKey(resource_name: str,
                            args: RepositoryDeployKeyArgs,
                            opts: Optional[ResourceOptions] = 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.
    
    
    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.

    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

    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.

    ReadOnly 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.

    ReadOnly 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.

    readOnly 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.

    readOnly 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.

    readOnly 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)
    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.
    The following state arguments are supported:
    Etag string
    Key string
    A SSH key.
    ReadOnly 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.
    ReadOnly 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.
    readOnly 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.
    readOnly 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.
    readOnly 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
    

    Package Details

    Repository
    GitHub pulumi/pulumi-github
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the github Terraform Provider.
    github logo
    GitHub v6.1.0 published on Monday, Mar 11, 2024 by Pulumi