1. Packages
  2. Linode Provider
  3. API Docs
  4. SshKey
Linode v4.30.1 published on Thursday, Nov 21, 2024 by Pulumi

linode.SshKey

Explore with Pulumi AI

linode logo
Linode v4.30.1 published on Thursday, Nov 21, 2024 by Pulumi

    Provides a Linode SSH Key resource. This can be used to create, modify, and delete Linodes SSH Keys. Managed SSH Keys allow instances to be created with a list of Linode usernames, whose SSH keys will be automatically applied to the root account’s ~/.ssh/authorized_keys file. For more information, see the Linode APIv4 docs.

    NOTE: This does not generate a new ssh key, you must have an existing key generated and saved locally.

    Example Usage

    The following example shows how one might use this resource to configure a SSH Key for access to a Linode Instance.

    import * as pulumi from "@pulumi/pulumi";
    import * as linode from "@pulumi/linode";
    import * as std from "@pulumi/std";
    
    const foo = new linode.SshKey("foo", {
        label: "foo",
        sshKey: std.file({
            input: "~/.ssh/id_rsa.pub",
        }).then(invoke => std.chomp({
            input: invoke.result,
        })).then(invoke => invoke.result),
    });
    const fooInstance = new linode.Instance("foo", {
        image: "linode/ubuntu22.04",
        label: "foo",
        region: "us-east",
        type: "g6-nanode-1",
        authorizedKeys: [foo.sshKey],
        rootPass: "...",
    });
    
    import pulumi
    import pulumi_linode as linode
    import pulumi_std as std
    
    foo = linode.SshKey("foo",
        label="foo",
        ssh_key=std.chomp(input=std.file(input="~/.ssh/id_rsa.pub").result).result)
    foo_instance = linode.Instance("foo",
        image="linode/ubuntu22.04",
        label="foo",
        region="us-east",
        type="g6-nanode-1",
        authorized_keys=[foo.ssh_key],
        root_pass="...")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-linode/sdk/v4/go/linode"
    	"github.com/pulumi/pulumi-std/sdk/go/std"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		invokeChomp, err := std.Chomp(ctx, &std.ChompArgs{
    			Input: std.File(ctx, &std.FileArgs{
    				Input: "~/.ssh/id_rsa.pub",
    			}, nil).Result,
    		}, nil)
    		if err != nil {
    			return err
    		}
    		foo, err := linode.NewSshKey(ctx, "foo", &linode.SshKeyArgs{
    			Label:  pulumi.String("foo"),
    			SshKey: pulumi.String(invokeChomp.Result),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = linode.NewInstance(ctx, "foo", &linode.InstanceArgs{
    			Image:  pulumi.String("linode/ubuntu22.04"),
    			Label:  pulumi.String("foo"),
    			Region: pulumi.String("us-east"),
    			Type:   pulumi.String("g6-nanode-1"),
    			AuthorizedKeys: pulumi.StringArray{
    				foo.SshKey,
    			},
    			RootPass: pulumi.String("..."),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Linode = Pulumi.Linode;
    using Std = Pulumi.Std;
    
    return await Deployment.RunAsync(() => 
    {
        var foo = new Linode.SshKey("foo", new()
        {
            Label = "foo",
            SshKeyName = Std.File.Invoke(new()
            {
                Input = "~/.ssh/id_rsa.pub",
            }).Apply(invoke => Std.Chomp.Invoke(new()
            {
                Input = invoke.Result,
            })).Apply(invoke => invoke.Result),
        });
    
        var fooInstance = new Linode.Instance("foo", new()
        {
            Image = "linode/ubuntu22.04",
            Label = "foo",
            Region = "us-east",
            Type = "g6-nanode-1",
            AuthorizedKeys = new[]
            {
                foo.SshKeyName,
            },
            RootPass = "...",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.linode.SshKey;
    import com.pulumi.linode.SshKeyArgs;
    import com.pulumi.linode.Instance;
    import com.pulumi.linode.InstanceArgs;
    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) {
            var foo = new SshKey("foo", SshKeyArgs.builder()
                .label("foo")
                .sshKey(StdFunctions.chomp(ChompArgs.builder()
                    .input(StdFunctions.file(FileArgs.builder()
                        .input("~/.ssh/id_rsa.pub")
                        .build()).result())
                    .build()).result())
                .build());
    
            var fooInstance = new Instance("fooInstance", InstanceArgs.builder()
                .image("linode/ubuntu22.04")
                .label("foo")
                .region("us-east")
                .type("g6-nanode-1")
                .authorizedKeys(foo.sshKey())
                .rootPass("...")
                .build());
    
        }
    }
    
    resources:
      foo:
        type: linode:SshKey
        properties:
          label: foo
          sshKey:
            fn::invoke:
              Function: std:chomp
              Arguments:
                input:
                  fn::invoke:
                    Function: std:file
                    Arguments:
                      input: ~/.ssh/id_rsa.pub
                    Return: result
              Return: result
      fooInstance:
        type: linode:Instance
        name: foo
        properties:
          image: linode/ubuntu22.04
          label: foo
          region: us-east
          type: g6-nanode-1
          authorizedKeys:
            - ${foo.sshKey}
          rootPass: '...'
    

    Create SshKey Resource

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

    Constructor syntax

    new SshKey(name: string, args: SshKeyArgs, opts?: CustomResourceOptions);
    @overload
    def SshKey(resource_name: str,
               args: SshKeyArgs,
               opts: Optional[ResourceOptions] = None)
    
    @overload
    def SshKey(resource_name: str,
               opts: Optional[ResourceOptions] = None,
               label: Optional[str] = None,
               ssh_key: Optional[str] = None)
    func NewSshKey(ctx *Context, name string, args SshKeyArgs, opts ...ResourceOption) (*SshKey, error)
    public SshKey(string name, SshKeyArgs args, CustomResourceOptions? opts = null)
    public SshKey(String name, SshKeyArgs args)
    public SshKey(String name, SshKeyArgs args, CustomResourceOptions options)
    
    type: linode:SshKey
    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 SshKeyArgs
    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 SshKeyArgs
    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 SshKeyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args SshKeyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args SshKeyArgs
    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 sshKeyResource = new Linode.SshKey("sshKeyResource", new()
    {
        Label = "string",
        SshKeyName = "string",
    });
    
    example, err := linode.NewSshKey(ctx, "sshKeyResource", &linode.SshKeyArgs{
    	Label:  pulumi.String("string"),
    	SshKey: pulumi.String("string"),
    })
    
    var sshKeyResource = new SshKey("sshKeyResource", SshKeyArgs.builder()
        .label("string")
        .sshKey("string")
        .build());
    
    ssh_key_resource = linode.SshKey("sshKeyResource",
        label="string",
        ssh_key="string")
    
    const sshKeyResource = new linode.SshKey("sshKeyResource", {
        label: "string",
        sshKey: "string",
    });
    
    type: linode:SshKey
    properties:
        label: string
        sshKey: string
    

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

    Label string
    A label for the SSH Key.
    SshKeyName string
    The public SSH Key, which is used to authenticate to the root user of the Linodes you deploy.
    Label string
    A label for the SSH Key.
    SshKey string
    The public SSH Key, which is used to authenticate to the root user of the Linodes you deploy.
    label String
    A label for the SSH Key.
    sshKey String
    The public SSH Key, which is used to authenticate to the root user of the Linodes you deploy.
    label string
    A label for the SSH Key.
    sshKey string
    The public SSH Key, which is used to authenticate to the root user of the Linodes you deploy.
    label str
    A label for the SSH Key.
    ssh_key str
    The public SSH Key, which is used to authenticate to the root user of the Linodes you deploy.
    label String
    A label for the SSH Key.
    sshKey String
    The public SSH Key, which is used to authenticate to the root user of the Linodes you deploy.

    Outputs

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

    Created string
    The date this SSH Key was created.
    Id string
    The provider-assigned unique ID for this managed resource.
    Created string
    The date this SSH Key was created.
    Id string
    The provider-assigned unique ID for this managed resource.
    created String
    The date this SSH Key was created.
    id String
    The provider-assigned unique ID for this managed resource.
    created string
    The date this SSH Key was created.
    id string
    The provider-assigned unique ID for this managed resource.
    created str
    The date this SSH Key was created.
    id str
    The provider-assigned unique ID for this managed resource.
    created String
    The date this SSH Key was created.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing SshKey Resource

    Get an existing SshKey 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?: SshKeyState, opts?: CustomResourceOptions): SshKey
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            created: Optional[str] = None,
            label: Optional[str] = None,
            ssh_key: Optional[str] = None) -> SshKey
    func GetSshKey(ctx *Context, name string, id IDInput, state *SshKeyState, opts ...ResourceOption) (*SshKey, error)
    public static SshKey Get(string name, Input<string> id, SshKeyState? state, CustomResourceOptions? opts = null)
    public static SshKey get(String name, Output<String> id, SshKeyState 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:
    Created string
    The date this SSH Key was created.
    Label string
    A label for the SSH Key.
    SshKeyName string
    The public SSH Key, which is used to authenticate to the root user of the Linodes you deploy.
    Created string
    The date this SSH Key was created.
    Label string
    A label for the SSH Key.
    SshKey string
    The public SSH Key, which is used to authenticate to the root user of the Linodes you deploy.
    created String
    The date this SSH Key was created.
    label String
    A label for the SSH Key.
    sshKey String
    The public SSH Key, which is used to authenticate to the root user of the Linodes you deploy.
    created string
    The date this SSH Key was created.
    label string
    A label for the SSH Key.
    sshKey string
    The public SSH Key, which is used to authenticate to the root user of the Linodes you deploy.
    created str
    The date this SSH Key was created.
    label str
    A label for the SSH Key.
    ssh_key str
    The public SSH Key, which is used to authenticate to the root user of the Linodes you deploy.
    created String
    The date this SSH Key was created.
    label String
    A label for the SSH Key.
    sshKey String
    The public SSH Key, which is used to authenticate to the root user of the Linodes you deploy.

    Import

    Linodes SSH Keys can be imported using the Linode SSH Key id, e.g.

    $ pulumi import linode:index/sshKey:SshKey mysshkey 1234567
    

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

    Package Details

    Repository
    Linode pulumi/pulumi-linode
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the linode Terraform Provider.
    linode logo
    Linode v4.30.1 published on Thursday, Nov 21, 2024 by Pulumi