gitlab_deploy_key_enable (Resource)

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

Example Usage

# 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
}

Schema

Required

Optional

Read-Only

Import

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