gitlab_user_gpgkey (Resource)

The gitlab_user_gpgkey resource allows to manage the lifecycle of a GPG key assigned to the current user or a specific user.

Upstream API: GitLab REST API docs

Example Usage

data "gitlab_user" "example" {
  username = "example-user"
}

# Manages a GPG key for the specified user. An admin token is required if `user_id` is specified.
resource "gitlab_user_gpgkey" "example" {
  user_id = data.gitlab_user.example.id
  key     = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n...\n-----END PGP PUBLIC KEY BLOCK-----"
}

# Manages a GPG key for the current user
resource "gitlab_user_gpgkey" "example_user" {
  key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n...\n-----END PGP PUBLIC KEY BLOCK-----"
}

Schema

Required

Optional

Read-Only

Import

Import is supported using the following syntax:

# You can import a GPG key for a specific user using an id made up of `{user-id}:{key}`, e.g.
terraform import gitlab_user_gpgkey.example 42:1

# Alternatively, you can import a GPG key for the current user using an id made up of `{key}`, e.g.
terraform import gitlab_user_gpgkey.example_user 1