The gitlab_user_sshkey
resource allows to manage the lifecycle of an SSH key assigned to a user.
Upstream API: GitLab API docs
data "gitlab_user" "example" {
username = "example-user"
}
resource "gitlab_user_sshkey" "example" {
user_id = data.gitlab_user.example.id
title = "example-key"
key = "ssh-ed25519 AAAA..."
expires_at = "2016-01-21T00:00:00.000Z"
}
key
(String) The ssh key. The SSH key comment
(trailing part) is optional and ignored for diffing, because GitLab overrides it with the username and GitLab hostname.title
(String) The title of the ssh key.expires_at
(String) The expiration date of the SSH key in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)user_id
(Number) The ID or username of the user. If this field is omitted, this resource manages a SSH key for the current user. Otherwise, this resource manages a SSH 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 ssh key.Import is supported using the following syntax:
# You can import a user ssh key using an id made up of `{user-id}:{key}`, e.g.
terraform import gitlab_user_sshkey.example 42:1