Skip to content

Latest commit

 

History

History
65 lines (46 loc) · 2.22 KB

user_gpgkey.md

File metadata and controls

65 lines (46 loc) · 2.22 KB
page_title subcategory description
gitlab_user_gpgkey Resource - terraform-provider-gitlab
The gitlab_user_gpgkey resource allows to manage the lifecycle of a GPG key assigned to the current user or a specific user. -> Managing GPG keys for arbitrary users requires admin privileges. Upstream API: GitLab REST API docs https://docs.gitlab.com/ee/api/users.html#get-a-specific-gpg-key

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.

-> Managing GPG keys for arbitrary users requires admin privileges.

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

  • key (String) The armored GPG public key.

Optional

  • 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.

Read-Only

  • 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

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