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
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-----"
}
key
(String) The armored GPG public key.user_id
(Number) The ID of the user to add the GPG key to. If this field is omitted, this resource manages a GPG key for the current user. Otherwise, this resource manages a GPG key for the specified user, and an admin token is required.created_at
(String) The time when this key was created in GitLab.id
(String) The ID of this resource.key_id
(Number) The ID of the GPG key.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