Deploy Key Enable
The gitlab.DeployKeyEnable
resource allows to enable an already existing deploy key (see gitlab.DeployKey resource
) for a specific project. Upstream API: GitLab REST API docs
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as gitlab from "@pulumi/gitlab";
// A repo to host the deployment key
const parentProject = new gitlab.Project("parentProject", {});
// A second repo to use the deployment key from the parent project
const fooProject = new gitlab.Project("fooProject", {});
// Upload a deployment key for the parent repo
const parentDeployKey = new gitlab.DeployKey("parentDeployKey", {
project: parentProject.id,
title: "Example deploy key",
key: "ssh-ed25519 AAAA...",
});
// Enable the deployment key on the second repo
const fooDeployKeyEnable = new gitlab.DeployKeyEnable("fooDeployKeyEnable", {
project: fooProject.id,
keyId: parentDeployKey.deployKeyId,
});
Content copied to clipboard
import pulumi
import pulumi_gitlab as gitlab
# A repo to host the deployment key
parent_project = gitlab.Project("parentProject")
# A second repo to use the deployment key from the parent project
foo_project = gitlab.Project("fooProject")
# Upload a deployment key for the parent repo
parent_deploy_key = gitlab.DeployKey("parentDeployKey",
project=parent_project.id,
title="Example deploy key",
key="ssh-ed25519 AAAA...")
# Enable the deployment key on the second repo
foo_deploy_key_enable = gitlab.DeployKeyEnable("fooDeployKeyEnable",
project=foo_project.id,
key_id=parent_deploy_key.deploy_key_id)
Content copied to clipboard
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using GitLab = Pulumi.GitLab;
return await Deployment.RunAsync(() =>
{
// A repo to host the deployment key
var parentProject = new GitLab.Project("parentProject");
// A second repo to use the deployment key from the parent project
var fooProject = new GitLab.Project("fooProject");
// Upload a deployment key for the parent repo
var parentDeployKey = new GitLab.DeployKey("parentDeployKey", new()
{
Project = parentProject.Id,
Title = "Example deploy key",
Key = "ssh-ed25519 AAAA...",
});
// Enable the deployment key on the second repo
var fooDeployKeyEnable = new GitLab.DeployKeyEnable("fooDeployKeyEnable", new()
{
Project = fooProject.Id,
KeyId = parentDeployKey.DeployKeyId,
});
});
Content copied to clipboard
package main
import (
"github.com/pulumi/pulumi-gitlab/sdk/v6/go/gitlab"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
// A repo to host the deployment key
parentProject, err := gitlab.NewProject(ctx, "parentProject", nil)
if err != nil {
return err
}
// A second repo to use the deployment key from the parent project
fooProject, err := gitlab.NewProject(ctx, "fooProject", nil)
if err != nil {
return err
}
// Upload a deployment key for the parent repo
parentDeployKey, err := gitlab.NewDeployKey(ctx, "parentDeployKey", &gitlab.DeployKeyArgs{
Project: parentProject.ID(),
Title: pulumi.String("Example deploy key"),
Key: pulumi.String("ssh-ed25519 AAAA..."),
})
if err != nil {
return err
}
// Enable the deployment key on the second repo
_, err = gitlab.NewDeployKeyEnable(ctx, "fooDeployKeyEnable", &gitlab.DeployKeyEnableArgs{
Project: fooProject.ID(),
KeyId: parentDeployKey.DeployKeyId,
})
if err != nil {
return err
}
return nil
})
}
Content copied to clipboard
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gitlab.Project;
import com.pulumi.gitlab.DeployKey;
import com.pulumi.gitlab.DeployKeyArgs;
import com.pulumi.gitlab.DeployKeyEnable;
import com.pulumi.gitlab.DeployKeyEnableArgs;
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) {
// A repo to host the deployment key
var parentProject = new Project("parentProject");
// A second repo to use the deployment key from the parent project
var fooProject = new Project("fooProject");
// Upload a deployment key for the parent repo
var parentDeployKey = new DeployKey("parentDeployKey", DeployKeyArgs.builder()
.project(parentProject.id())
.title("Example deploy key")
.key("ssh-ed25519 AAAA...")
.build());
// Enable the deployment key on the second repo
var fooDeployKeyEnable = new DeployKeyEnable("fooDeployKeyEnable", DeployKeyEnableArgs.builder()
.project(fooProject.id())
.keyId(parentDeployKey.deployKeyId())
.build());
}
}
Content copied to clipboard
resources:
# A repo to host the deployment key
parentProject:
type: gitlab:Project
# A second repo to use the deployment key from the parent project
fooProject:
type: gitlab:Project
# Upload a deployment key for the parent repo
parentDeployKey:
type: gitlab:DeployKey
properties:
project: ${parentProject.id}
title: Example deploy key
key: ssh-ed25519 AAAA...
# Enable the deployment key on the second repo
fooDeployKeyEnable:
type: gitlab:DeployKeyEnable
properties:
project: ${fooProject.id}
keyId: ${parentDeployKey.deployKeyId}
Content copied to clipboard
Import
GitLab enabled deploy keys can be imported using an id made up of {project_id}:{deploy_key_id}
, e.g. project_id
can be whatever the get_single_project takes for its :id
value, so for example:
$ pulumi import gitlab:index/deployKeyEnable:DeployKeyEnable example 12345:67890
Content copied to clipboard
$ pulumi import gitlab:index/deployKeyEnable:DeployKeyEnable example richardc/example:67890
Content copied to clipboard