UserGpgKey

class UserGpgKey : KotlinCustomResource

The gitlab.UserGpgKey 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

import * as pulumi from "@pulumi/pulumi";
import * as gitlab from "@pulumi/gitlab";
const exampleUser = gitlab.getUser({
username: "example-user",
});
// Manages a GPG key for the specified user. An admin token is required if `user_id` is specified.
const exampleUserGpgKey = new gitlab.UserGpgKey("exampleUserGpgKey", {
userId: exampleUser.then(exampleUser => exampleUser.id),
key: `-----BEGIN PGP PUBLIC KEY BLOCK-----
...
-----END PGP PUBLIC KEY BLOCK-----`,
});
// Manages a GPG key for the current user
const exampleUserUserGpgKey = new gitlab.UserGpgKey("exampleUserUserGpgKey", {key: `-----BEGIN PGP PUBLIC KEY BLOCK-----
...
-----END PGP PUBLIC KEY BLOCK-----`});
import pulumi
import pulumi_gitlab as gitlab
example_user = gitlab.get_user(username="example-user")
# Manages a GPG key for the specified user. An admin token is required if `user_id` is specified.
example_user_gpg_key = gitlab.UserGpgKey("exampleUserGpgKey",
user_id=example_user.id,
key="""-----BEGIN PGP PUBLIC KEY BLOCK-----
...
-----END PGP PUBLIC KEY BLOCK-----""")
# Manages a GPG key for the current user
example_user_user_gpg_key = gitlab.UserGpgKey("exampleUserUserGpgKey", key="""-----BEGIN PGP PUBLIC KEY BLOCK-----
...
-----END PGP PUBLIC KEY BLOCK-----""")
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",
});
// Manages a GPG key for the specified user. An admin token is required if `user_id` is specified.
var exampleUserGpgKey = new GitLab.UserGpgKey("exampleUserGpgKey", new()
{
UserId = exampleUser.Apply(getUserResult => getUserResult.Id),
Key = @"-----BEGIN PGP PUBLIC KEY BLOCK-----
...
-----END PGP PUBLIC KEY BLOCK-----",
});
// Manages a GPG key for the current user
var exampleUserUserGpgKey = new GitLab.UserGpgKey("exampleUserUserGpgKey", new()
{
Key = @"-----BEGIN PGP PUBLIC KEY BLOCK-----
...
-----END PGP PUBLIC KEY BLOCK-----",
});
});
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
}
// Manages a GPG key for the specified user. An admin token is required if `user_id` is specified.
_, err = gitlab.NewUserGpgKey(ctx, "exampleUserGpgKey", &gitlab.UserGpgKeyArgs{
UserId: pulumi.String(exampleUser.Id),
Key: pulumi.String("-----BEGIN PGP PUBLIC KEY BLOCK-----\n...\n-----END PGP PUBLIC KEY BLOCK-----"),
})
if err != nil {
return err
}
// Manages a GPG key for the current user
_, err = gitlab.NewUserGpgKey(ctx, "exampleUserUserGpgKey", &gitlab.UserGpgKeyArgs{
Key: pulumi.String("-----BEGIN PGP PUBLIC KEY BLOCK-----\n...\n-----END PGP PUBLIC KEY BLOCK-----"),
})
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.UserGpgKey;
import com.pulumi.gitlab.UserGpgKeyArgs;
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());
// Manages a GPG key for the specified user. An admin token is required if `user_id` is specified.
var exampleUserGpgKey = new UserGpgKey("exampleUserGpgKey", UserGpgKeyArgs.builder()
.userId(exampleUser.applyValue(getUserResult -> getUserResult.id()))
.key("""
-----BEGIN PGP PUBLIC KEY BLOCK-----
...
-----END PGP PUBLIC KEY BLOCK----- """)
.build());
// Manages a GPG key for the current user
var exampleUserUserGpgKey = new UserGpgKey("exampleUserUserGpgKey", UserGpgKeyArgs.builder()
.key("""
-----BEGIN PGP PUBLIC KEY BLOCK-----
...
-----END PGP PUBLIC KEY BLOCK----- """)
.build());
}
}
resources:
# Manages a GPG key for the specified user. An admin token is required if `user_id` is specified.
exampleUserGpgKey:
type: gitlab:UserGpgKey
properties:
userId: ${exampleUser.id}
key: |-
-----BEGIN PGP PUBLIC KEY BLOCK-----
...
-----END PGP PUBLIC KEY BLOCK-----
# Manages a GPG key for the current user
exampleUserUserGpgKey:
type: gitlab:UserGpgKey
properties:
key: |-
-----BEGIN PGP PUBLIC KEY BLOCK-----
...
-----END PGP PUBLIC KEY BLOCK-----
variables:
exampleUser:
fn::invoke:
Function: gitlab:getUser
Arguments:
username: example-user

Import

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

$ pulumi import gitlab:index/userGpgKey:UserGpgKey example 42:1

Alternatively, you can import a GPG key for the current user using an id made up of {key}, e.g.

$ pulumi import gitlab:index/userGpgKey:UserGpgKey example_user 1

Properties

Link copied to clipboard
val createdAt: Output<String>

The time when this key was created in GitLab.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val key: Output<String>

The armored GPG public key.

Link copied to clipboard
val keyId: Output<Int>

The ID of the GPG key.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val urn: Output<String>
Link copied to clipboard
val userId: Output<Int>?

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.