UserSshKey

class UserSshKey : KotlinCustomResource

The gitlab.UserSshKey resource allows to manage the lifecycle of an SSH key assigned to a user. Upstream API: GitLab API docs

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as gitlab from "@pulumi/gitlab";
const exampleUser = gitlab.getUser({
username: "example-user",
});
const exampleUserSshKey = new gitlab.UserSshKey("exampleUserSshKey", {
userId: exampleUser.then(exampleUser => exampleUser.id),
title: "example-key",
key: "ssh-ed25519 AAAA...",
expiresAt: "2016-01-21T00:00:00.000Z",
});
import pulumi
import pulumi_gitlab as gitlab
example_user = gitlab.get_user(username="example-user")
example_user_ssh_key = gitlab.UserSshKey("exampleUserSshKey",
user_id=example_user.id,
title="example-key",
key="ssh-ed25519 AAAA...",
expires_at="2016-01-21T00:00:00.000Z")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using GitLab = Pulumi.GitLab;
return await Deployment.RunAsync(() =>
{
var exampleUser = GitLab.GetUser.Invoke(new()
{
Username = "example-user",
});
var exampleUserSshKey = new GitLab.UserSshKey("exampleUserSshKey", new()
{
UserId = exampleUser.Apply(getUserResult => getUserResult.Id),
Title = "example-key",
Key = "ssh-ed25519 AAAA...",
ExpiresAt = "2016-01-21T00:00:00.000Z",
});
});
package main
import (
"github.com/pulumi/pulumi-gitlab/sdk/v6/go/gitlab"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
exampleUser, err := gitlab.LookupUser(ctx, &gitlab.LookupUserArgs{
Username: pulumi.StringRef("example-user"),
}, nil)
if err != nil {
return err
}
_, err = gitlab.NewUserSshKey(ctx, "exampleUserSshKey", &gitlab.UserSshKeyArgs{
UserId: pulumi.String(exampleUser.Id),
Title: pulumi.String("example-key"),
Key: pulumi.String("ssh-ed25519 AAAA..."),
ExpiresAt: pulumi.String("2016-01-21T00:00:00.000Z"),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gitlab.GitlabFunctions;
import com.pulumi.gitlab.inputs.GetUserArgs;
import com.pulumi.gitlab.UserSshKey;
import com.pulumi.gitlab.UserSshKeyArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var exampleUser = GitlabFunctions.getUser(GetUserArgs.builder()
.username("example-user")
.build());
var exampleUserSshKey = new UserSshKey("exampleUserSshKey", UserSshKeyArgs.builder()
.userId(exampleUser.applyValue(getUserResult -> getUserResult.id()))
.title("example-key")
.key("ssh-ed25519 AAAA...")
.expiresAt("2016-01-21T00:00:00.000Z")
.build());
}
}
resources:
exampleUserSshKey:
type: gitlab:UserSshKey
properties:
userId: ${exampleUser.id}
title: example-key
key: ssh-ed25519 AAAA...
expiresAt: 2016-01-21T00:00:00.000Z
variables:
exampleUser:
fn::invoke:
Function: gitlab:getUser
Arguments:
username: example-user

Import

You can import a user ssh key using an id made up of {user-id}:{key}, e.g.

$ pulumi import gitlab:index/userSshKey:UserSshKey example 42:1

Properties

Link copied to clipboard
val createdAt: Output<String>

The time when this key was created in GitLab.

Link copied to clipboard
val expiresAt: Output<String>?

The expiration date of the SSH key in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val key: Output<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.

Link copied to clipboard
val keyId: Output<Int>

The ID of the ssh key.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val title: Output<String>

The title of the ssh key.

Link copied to clipboard
val urn: Output<String>
Link copied to clipboard
val userId: Output<Int>

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.