User Gpg Key
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
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());
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());
var exampleUserUserGpgKey = new UserGpgKey("exampleUserUserGpgKey", UserGpgKeyArgs.builder()
.key("""
-----BEGIN PGP PUBLIC KEY BLOCK-----
...
-----END PGP PUBLIC KEY BLOCK----- """)
.build());
}
}
Content copied to clipboard
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
Content copied to clipboard
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
Content copied to clipboard