gitlab.UserSshKey
Explore with Pulumi AI
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",
});
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")
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
})
}
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",
});
});
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());
}
}
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
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.
Constructor 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
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
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.
- Expires
At string - 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.
- Expires
At string - 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.
- expires
At String - The expiration date of the SSH key in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)
- user
Id 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.
- expires
At string - The expiration date of the SSH key in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)
- user
Id 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.
- expires
At String - The expiration date of the SSH key in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)
- user
Id 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:
- 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.
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.
- Created
At string - The time when this key was created in GitLab.
- Expires
At 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. - Key
Id int - The ID of the ssh key.
- Title string
- 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.
- Created
At string - The time when this key was created in GitLab.
- Expires
At 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. - Key
Id int - The ID of the ssh key.
- Title string
- 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.
- created
At String - The time when this key was created in GitLab.
- expires
At 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. - key
Id Integer - The ID of the ssh key.
- title String
- The title of the ssh key.
- user
Id 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.
- created
At string - The time when this key was created in GitLab.
- expires
At 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. - key
Id number - The ID of the ssh key.
- title string
- The title of the ssh key.
- user
Id 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.
- created
At String - The time when this key was created in GitLab.
- expires
At 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. - key
Id Number - The ID of the ssh key.
- title String
- The title of the ssh key.
- user
Id 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.