1. Packages
  2. GitLab
  3. API Docs
  4. UserSshKey
GitLab v6.11.0 published on Friday, Apr 19, 2024 by Pulumi

gitlab.UserSshKey

Explore with Pulumi AI

gitlab logo
GitLab v6.11.0 published on Friday, Apr 19, 2024 by Pulumi

    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")
    
    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
    	})
    }
    
    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 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
    

    Create UserSshKey Resource

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

    Constructor syntax

    new UserSshKey(name: string, args: UserSshKeyArgs, opts?: CustomResourceOptions);
    @overload
    def UserSshKey(resource_name: str,
                   args: UserSshKeyArgs,
                   opts: Optional[ResourceOptions] = None)
    
    @overload
    def UserSshKey(resource_name: str,
                   opts: Optional[ResourceOptions] = None,
                   key: Optional[str] = None,
                   title: Optional[str] = None,
                   expires_at: Optional[str] = None,
                   user_id: Optional[int] = None)
    func NewUserSshKey(ctx *Context, name string, args UserSshKeyArgs, opts ...ResourceOption) (*UserSshKey, error)
    public UserSshKey(string name, UserSshKeyArgs args, CustomResourceOptions? opts = null)
    public UserSshKey(String name, UserSshKeyArgs args)
    public UserSshKey(String name, UserSshKeyArgs args, CustomResourceOptions options)
    
    type: gitlab:UserSshKey
    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 UserSshKeyArgs
    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 UserSshKeyArgs
    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 UserSshKeyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args UserSshKeyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args UserSshKeyArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Example

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

    var userSshKeyResource = new GitLab.UserSshKey("userSshKeyResource", new()
    {
        Key = "string",
        Title = "string",
        ExpiresAt = "string",
        UserId = 0,
    });
    
    example, err := gitlab.NewUserSshKey(ctx, "userSshKeyResource", &gitlab.UserSshKeyArgs{
    	Key:       pulumi.String("string"),
    	Title:     pulumi.String("string"),
    	ExpiresAt: pulumi.String("string"),
    	UserId:    pulumi.Int(0),
    })
    
    var userSshKeyResource = new UserSshKey("userSshKeyResource", UserSshKeyArgs.builder()        
        .key("string")
        .title("string")
        .expiresAt("string")
        .userId(0)
        .build());
    
    user_ssh_key_resource = gitlab.UserSshKey("userSshKeyResource",
        key="string",
        title="string",
        expires_at="string",
        user_id=0)
    
    const userSshKeyResource = new gitlab.UserSshKey("userSshKeyResource", {
        key: "string",
        title: "string",
        expiresAt: "string",
        userId: 0,
    });
    
    type: gitlab:UserSshKey
    properties:
        expiresAt: string
        key: string
        title: string
        userId: 0
    

    UserSshKey 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 UserSshKey resource accepts the following input properties:

    Key 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.
    Title string
    The title of the ssh key.
    ExpiresAt string
    The expiration date of the SSH key in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)
    UserId 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.
    Key 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.
    Title string
    The title of the ssh key.
    ExpiresAt string
    The expiration date of the SSH key in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)
    UserId 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.
    key 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.
    title String
    The title of the ssh key.
    expiresAt String
    The expiration date of the SSH key in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)
    userId Integer
    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.
    key 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.
    title string
    The title of the ssh key.
    expiresAt string
    The expiration date of the SSH key in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)
    userId number
    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.
    key str
    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.
    title str
    The title of the ssh key.
    expires_at str
    The expiration date of the SSH key in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)
    user_id 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.
    key 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.
    title String
    The title of the ssh key.
    expiresAt String
    The expiration date of the SSH key in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)
    userId Number
    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.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the UserSshKey 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 ssh 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 ssh 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 ssh 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 ssh 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 ssh 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 ssh key.

    Look up Existing UserSshKey Resource

    Get an existing UserSshKey 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?: UserSshKeyState, opts?: CustomResourceOptions): UserSshKey
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            created_at: Optional[str] = None,
            expires_at: Optional[str] = None,
            key: Optional[str] = None,
            key_id: Optional[int] = None,
            title: Optional[str] = None,
            user_id: Optional[int] = None) -> UserSshKey
    func GetUserSshKey(ctx *Context, name string, id IDInput, state *UserSshKeyState, opts ...ResourceOption) (*UserSshKey, error)
    public static UserSshKey Get(string name, Input<string> id, UserSshKeyState? state, CustomResourceOptions? opts = null)
    public static UserSshKey get(String name, Output<String> id, UserSshKeyState 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.
    ExpiresAt string
    The expiration date of the SSH key in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)
    Key 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.
    KeyId int
    The ID of the ssh key.
    Title string
    The title of the ssh key.
    UserId 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.
    CreatedAt string
    The time when this key was created in GitLab.
    ExpiresAt string
    The expiration date of the SSH key in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)
    Key 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.
    KeyId int
    The ID of the ssh key.
    Title string
    The title of the ssh key.
    UserId 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.
    createdAt String
    The time when this key was created in GitLab.
    expiresAt String
    The expiration date of the SSH key in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)
    key 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.
    keyId Integer
    The ID of the ssh key.
    title String
    The title of the ssh key.
    userId Integer
    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.
    createdAt string
    The time when this key was created in GitLab.
    expiresAt string
    The expiration date of the SSH key in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)
    key 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.
    keyId number
    The ID of the ssh key.
    title string
    The title of the ssh key.
    userId number
    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.
    created_at str
    The time when this key was created in GitLab.
    expires_at str
    The expiration date of the SSH key in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)
    key str
    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.
    key_id int
    The ID of the ssh key.
    title str
    The title of the ssh key.
    user_id 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.
    createdAt String
    The time when this key was created in GitLab.
    expiresAt String
    The expiration date of the SSH key in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)
    key 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.
    keyId Number
    The ID of the ssh key.
    title String
    The title of the ssh key.
    userId Number
    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.

    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
    

    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 v6.11.0 published on Friday, Apr 19, 2024 by Pulumi