User Ssh Key Args
data class UserSshKeyArgs(val expiresAt: Output<String>? = null, val key: Output<String>? = null, val title: Output<String>? = null, val userId: Output<Int>? = null) : ConvertibleToJava<UserSshKeyArgs>
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 example = gitlab.getUser({
username: "example-user",
});
const exampleUserSshKey = new gitlab.UserSshKey("example", {
userId: example.then(example => example.id),
title: "example-key",
key: "ssh-ed25519 AAAA...",
expiresAt: "2016-01-21T00:00:00.000Z",
});
Content copied to clipboard
import pulumi
import pulumi_gitlab as gitlab
example = gitlab.get_user(username="example-user")
example_user_ssh_key = gitlab.UserSshKey("example",
user_id=example.id,
title="example-key",
key="ssh-ed25519 AAAA...",
expires_at="2016-01-21T00:00:00.000Z")
Content copied to clipboard
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using GitLab = Pulumi.GitLab;
return await Deployment.RunAsync(() =>
{
var example = GitLab.GetUser.Invoke(new()
{
Username = "example-user",
});
var exampleUserSshKey = new GitLab.UserSshKey("example", new()
{
UserId = example.Apply(getUserResult => getUserResult.Id),
Title = "example-key",
Key = "ssh-ed25519 AAAA...",
ExpiresAt = "2016-01-21T00:00:00.000Z",
});
});
Content copied to clipboard
package main
import (
"github.com/pulumi/pulumi-gitlab/sdk/v8/go/gitlab"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := gitlab.LookupUser(ctx, &gitlab.LookupUserArgs{
Username: pulumi.StringRef("example-user"),
}, nil)
if err != nil {
return err
}
_, err = gitlab.NewUserSshKey(ctx, "example", &gitlab.UserSshKeyArgs{
UserId: pulumi.String(example.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
})
}
Content copied to clipboard
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 example = GitlabFunctions.getUser(GetUserArgs.builder()
.username("example-user")
.build());
var exampleUserSshKey = new UserSshKey("exampleUserSshKey", UserSshKeyArgs.builder()
.userId(example.applyValue(getUserResult -> getUserResult.id()))
.title("example-key")
.key("ssh-ed25519 AAAA...")
.expiresAt("2016-01-21T00:00:00.000Z")
.build());
}
}
Content copied to clipboard
resources:
exampleUserSshKey:
type: gitlab:UserSshKey
name: example
properties:
userId: ${example.id}
title: example-key
key: ssh-ed25519 AAAA...
expiresAt: 2016-01-21T00:00:00.000Z
variables:
example:
fn::invoke:
function: gitlab:getUser
arguments:
username: example-user
Content copied to clipboard
Import
Starting in Terraform v1.5.0 you can use an import block to import gitlab_user_sshkey
. For example: terraform import { to = gitlab_user_sshkey.example id = "see CLI command below for ID" } Import using the CLI is supported using the following syntax: 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
Content copied to clipboard