The gitlab_deploy_key_enable
resource allows to enable an already existing deploy key (see gitlab_deploy_key resource
) for a specific project.
Upstream API: GitLab REST API docs
# A repo to host the deployment key
resource "gitlab_project" "parent" {
name = "parent_project"
}
# A second repo to use the deployment key from the parent project
resource "gitlab_project" "foo" {
name = "foo_project"
}
# Upload a deployment key for the parent repo
resource "gitlab_deploy_key" "parent" {
project = gitlab_project.parent.id
title = "Example deploy key"
key = "ssh-ed25519 AAAA..."
}
# Enable the deployment key on the second repo
resource "gitlab_deploy_key_enable" "foo" {
project = gitlab_project.foo.id
key_id = gitlab_deploy_key.parent.deploy_key_id
}
key_id
(String) The Gitlab key id for the pre-existing deploy keyproject
(String) The name or id of the project to add the deploy key to.can_push
(Boolean) Can deploy key push to the project's repository.key
(String) Deploy key.title
(String) Deploy key's title.id
(String) The ID of this resource.Import is supported using the following syntax:
# 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 api][get_single_project] takes for
# its `:id` value, so for example:
terraform import gitlab_deploy_key_enable.example 12345:67890
terraform import gitlab_deploy_key_enable.example richardc/example:67890