1. Packages
  2. Gitlab Provider
  3. API Docs
  4. UserGpgKey
GitLab v8.4.1 published on Tuesday, Sep 24, 2024 by Pulumi

gitlab.UserGpgKey

Explore with Pulumi AI

gitlab logo
GitLab v8.4.1 published on Tuesday, Sep 24, 2024 by Pulumi

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

    Create UserGpgKey Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new UserGpgKey(name: string, args: UserGpgKeyArgs, opts?: CustomResourceOptions);
    @overload
    def UserGpgKey(resource_name: str,
                   args: UserGpgKeyArgs,
                   opts: Optional[ResourceOptions] = None)
    
    @overload
    def UserGpgKey(resource_name: str,
                   opts: Optional[ResourceOptions] = None,
                   key: Optional[str] = None,
                   user_id: Optional[int] = None)
    func NewUserGpgKey(ctx *Context, name string, args UserGpgKeyArgs, opts ...ResourceOption) (*UserGpgKey, error)
    public UserGpgKey(string name, UserGpgKeyArgs args, CustomResourceOptions? opts = null)
    public UserGpgKey(String name, UserGpgKeyArgs args)
    public UserGpgKey(String name, UserGpgKeyArgs args, CustomResourceOptions options)
    
    type: gitlab:UserGpgKey
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args UserGpgKeyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args UserGpgKeyArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args UserGpgKeyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args UserGpgKeyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args UserGpgKeyArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var userGpgKeyResource = new GitLab.UserGpgKey("userGpgKeyResource", new()
    {
        Key = "string",
        UserId = 0,
    });
    
    example, err := gitlab.NewUserGpgKey(ctx, "userGpgKeyResource", &gitlab.UserGpgKeyArgs{
    	Key:    pulumi.String("string"),
    	UserId: pulumi.Int(0),
    })
    
    var userGpgKeyResource = new UserGpgKey("userGpgKeyResource", UserGpgKeyArgs.builder()
        .key("string")
        .userId(0)
        .build());
    
    user_gpg_key_resource = gitlab.UserGpgKey("userGpgKeyResource",
        key="string",
        user_id=0)
    
    const userGpgKeyResource = new gitlab.UserGpgKey("userGpgKeyResource", {
        key: "string",
        userId: 0,
    });
    
    type: gitlab:UserGpgKey
    properties:
        key: string
        userId: 0
    

    UserGpgKey Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The UserGpgKey resource accepts the following input properties:

    Key string
    The armored GPG public key.
    UserId 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.
    Key string
    The armored GPG public key.
    UserId 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.
    key String
    The armored GPG public key.
    userId Integer
    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.
    key string
    The armored GPG public key.
    userId number
    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.
    key str
    The armored GPG public key.
    user_id 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.
    key String
    The armored GPG public key.
    userId Number
    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.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the UserGpgKey resource produces the following output properties:

    CreatedAt string
    The time when this key was created in GitLab.
    Id string
    The provider-assigned unique ID for this managed resource.
    KeyId int
    The ID of the GPG key.
    CreatedAt string
    The time when this key was created in GitLab.
    Id string
    The provider-assigned unique ID for this managed resource.
    KeyId int
    The ID of the GPG key.
    createdAt String
    The time when this key was created in GitLab.
    id String
    The provider-assigned unique ID for this managed resource.
    keyId Integer
    The ID of the GPG key.
    createdAt string
    The time when this key was created in GitLab.
    id string
    The provider-assigned unique ID for this managed resource.
    keyId number
    The ID of the GPG key.
    created_at str
    The time when this key was created in GitLab.
    id str
    The provider-assigned unique ID for this managed resource.
    key_id int
    The ID of the GPG key.
    createdAt String
    The time when this key was created in GitLab.
    id String
    The provider-assigned unique ID for this managed resource.
    keyId Number
    The ID of the GPG key.

    Look up Existing UserGpgKey Resource

    Get an existing UserGpgKey resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: UserGpgKeyState, opts?: CustomResourceOptions): UserGpgKey
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            created_at: Optional[str] = None,
            key: Optional[str] = None,
            key_id: Optional[int] = None,
            user_id: Optional[int] = None) -> UserGpgKey
    func GetUserGpgKey(ctx *Context, name string, id IDInput, state *UserGpgKeyState, opts ...ResourceOption) (*UserGpgKey, error)
    public static UserGpgKey Get(string name, Input<string> id, UserGpgKeyState? state, CustomResourceOptions? opts = null)
    public static UserGpgKey get(String name, Output<String> id, UserGpgKeyState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    CreatedAt string
    The time when this key was created in GitLab.
    Key string
    The armored GPG public key.
    KeyId int
    The ID of the GPG key.
    UserId 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.
    CreatedAt string
    The time when this key was created in GitLab.
    Key string
    The armored GPG public key.
    KeyId int
    The ID of the GPG key.
    UserId 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.
    createdAt String
    The time when this key was created in GitLab.
    key String
    The armored GPG public key.
    keyId Integer
    The ID of the GPG key.
    userId Integer
    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.
    createdAt string
    The time when this key was created in GitLab.
    key string
    The armored GPG public key.
    keyId number
    The ID of the GPG key.
    userId number
    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.
    created_at str
    The time when this key was created in GitLab.
    key str
    The armored GPG public key.
    key_id int
    The ID of the GPG key.
    user_id 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.
    createdAt String
    The time when this key was created in GitLab.
    key String
    The armored GPG public key.
    keyId Number
    The ID of the GPG key.
    userId Number
    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.

    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
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    GitLab pulumi/pulumi-gitlab
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the gitlab Terraform Provider.
    gitlab logo
    GitLab v8.4.1 published on Tuesday, Sep 24, 2024 by Pulumi