1. Packages
  2. Equinix
  3. API Docs
  4. metal
  5. SshKey
Equinix v0.21.0 published on Friday, Feb 28, 2025 by Equinix

equinix.metal.SshKey

Explore with Pulumi AI

Provides a resource to manage User SSH keys on your Equinix Metal user account. If you create a new device in a project, all the keys of the project’s collaborators will be injected to the device.

The link between User SSH key and device is implicit. If you want to make sure that a key will be copied to a device, you must ensure that the device resource depends_on the key resource.

Example Usage

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Equinix = Pulumi.Equinix;
using Std = Pulumi.Std;

return await Deployment.RunAsync(() => 
{
    var key1 = new Equinix.Metal.SshKey("key1", new()
    {
        Name = "terraform-1",
        PublicKey = Std.File.Invoke(new()
        {
            Input = "/home/terraform/.ssh/id_rsa.pub",
        }).Apply(invoke => invoke.Result),
    });

    var test = new Equinix.Metal.Device("test", new()
    {
        Hostname = "test-device",
        Plan = Equinix.Metal.Plan.C3SmallX86,
        Metro = "sv",
        OperatingSystem = Equinix.Metal.OperatingSystem.Ubuntu20_04,
        BillingCycle = Equinix.Metal.BillingCycle.Hourly,
        ProjectId = projectId,
    }, new CustomResourceOptions
    {
        DependsOn =
        {
            key1,
        },
    });

});
Copy
package main

import (
	"github.com/equinix/pulumi-equinix/sdk/go/equinix/metal"
	"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 {
		key1, err := metal.NewSshKey(ctx, "key1", &metal.SshKeyArgs{
			Name: pulumi.String("terraform-1"),
			PublicKey: pulumi.String(std.FileOutput(ctx, std.FileOutputArgs{
				Input: pulumi.String("/home/terraform/.ssh/id_rsa.pub"),
			}, nil).ApplyT(func(invoke std.FileResult) (*string, error) {
				return invoke.Result, nil
			}).(pulumi.StringPtrOutput)),
		})
		if err != nil {
			return err
		}
		_, err = metal.NewDevice(ctx, "test", &metal.DeviceArgs{
			Hostname:        pulumi.String("test-device"),
			Plan:            pulumi.String(metal.PlanC3SmallX86),
			Metro:           pulumi.String("sv"),
			OperatingSystem: pulumi.String(metal.OperatingSystem_Ubuntu20_04),
			BillingCycle:    pulumi.String(metal.BillingCycleHourly),
			ProjectId:       pulumi.Any(projectId),
		}, pulumi.DependsOn([]pulumi.Resource{
			key1,
		}))
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.equinix.metal.SshKey;
import com.pulumi.equinix.metal.SshKeyArgs;
import com.pulumi.std.StdFunctions;
import com.pulumi.std.inputs.FileArgs;
import com.pulumi.equinix.metal.Device;
import com.pulumi.equinix.metal.DeviceArgs;
import com.pulumi.resources.CustomResourceOptions;
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 key1 = new SshKey("key1", SshKeyArgs.builder()
            .name("terraform-1")
            .publicKey(StdFunctions.file(FileArgs.builder()
                .input("/home/terraform/.ssh/id_rsa.pub")
                .build()).applyValue(_invoke -> _invoke.result()))
            .build());

        var test = new Device("test", DeviceArgs.builder()
            .hostname("test-device")
            .plan("c3.small.x86")
            .metro("sv")
            .operatingSystem("ubuntu_20_04")
            .billingCycle("hourly")
            .projectId(projectId)
            .build(), CustomResourceOptions.builder()
                .dependsOn(key1)
                .build());

    }
}
Copy
import * as pulumi from "@pulumi/pulumi";
import * as equinix from "@equinix-labs/pulumi-equinix";
import * as std from "@pulumi/std";

const key1 = new equinix.metal.SshKey("key1", {
    name: "terraform-1",
    publicKey: std.fileOutput({
        input: "/home/terraform/.ssh/id_rsa.pub",
    }).apply(invoke => invoke.result),
});
const test = new equinix.metal.Device("test", {
    hostname: "test-device",
    plan: equinix.metal.Plan.C3SmallX86,
    metro: "sv",
    operatingSystem: equinix.metal.OperatingSystem.Ubuntu20_04,
    billingCycle: equinix.metal.BillingCycle.Hourly,
    projectId: projectId,
}, {
    dependsOn: [key1],
});
Copy
import pulumi
import pulumi_equinix as equinix
import pulumi_std as std

key1 = equinix.metal.SshKey("key1",
    name="terraform-1",
    public_key=std.file_output(input="/home/terraform/.ssh/id_rsa.pub").apply(lambda invoke: invoke.result))
test = equinix.metal.Device("test",
    hostname="test-device",
    plan=equinix.metal.Plan.C3_SMALL_X86,
    metro="sv",
    operating_system=equinix.metal.OperatingSystem.UBUNTU20_04,
    billing_cycle=equinix.metal.BillingCycle.HOURLY,
    project_id=project_id,
    opts = pulumi.ResourceOptions(depends_on=[key1]))
Copy
resources:
  # Create a new SSH key
  key1:
    type: equinix:metal:SshKey
    properties:
      name: terraform-1
      publicKey:
        fn::invoke:
          function: std:file
          arguments:
            input: /home/terraform/.ssh/id_rsa.pub
          return: result
  # Create new device with "key1" included. The device resource "depends_on" the
  # key, in order to make sure the key is created before the device.
  test:
    type: equinix:metal:Device
    properties:
      hostname: test-device
      plan: c3.small.x86
      metro: sv
      operatingSystem: ubuntu_20_04
      billingCycle: hourly
      projectId: ${projectId}
    options:
      dependsOn:
        - ${key1}
Copy

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,
           public_key: Optional[str] = None,
           name: 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: equinix:metal:SshKey
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. SshKeyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. 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 This property is required. string
The unique name of the resource.
args This property is required. SshKeyArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. SshKeyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. 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 Equinix.Metal.SshKey("sshKeyResource", new()
{
    PublicKey = "string",
    Name = "string",
});
Copy
example, err := metal.NewSshKey(ctx, "sshKeyResource", &metal.SshKeyArgs{
	PublicKey: pulumi.String("string"),
	Name:      pulumi.String("string"),
})
Copy
var sshKeyResource = new SshKey("sshKeyResource", SshKeyArgs.builder()
    .publicKey("string")
    .name("string")
    .build());
Copy
ssh_key_resource = equinix.metal.SshKey("sshKeyResource",
    public_key="string",
    name="string")
Copy
const sshKeyResource = new equinix.metal.SshKey("sshKeyResource", {
    publicKey: "string",
    name: "string",
});
Copy
type: equinix:metal:SshKey
properties:
    name: string
    publicKey: string
Copy

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:

PublicKey This property is required. string
The public key. If this is a file, it can be read using the file interpolation function
Name string
The name of the SSH key for identification
PublicKey This property is required. string
The public key. If this is a file, it can be read using the file interpolation function
Name string
The name of the SSH key for identification
publicKey This property is required. String
The public key. If this is a file, it can be read using the file interpolation function
name String
The name of the SSH key for identification
publicKey This property is required. string
The public key. If this is a file, it can be read using the file interpolation function
name string
The name of the SSH key for identification
public_key This property is required. str
The public key. If this is a file, it can be read using the file interpolation function
name str
The name of the SSH key for identification
publicKey This property is required. String
The public key. If this is a file, it can be read using the file interpolation function
name String
The name of the SSH key for identification

Outputs

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

Created string
The timestamp for when the SSH key was created.
Fingerprint string
The fingerprint of the SSH key.
Id string
The provider-assigned unique ID for this managed resource.
OwnerId string
The UUID of the Equinix Metal API User who owns this key.
Updated string
The timestamp for the last time the SSH key was updated.
Created string
The timestamp for when the SSH key was created.
Fingerprint string
The fingerprint of the SSH key.
Id string
The provider-assigned unique ID for this managed resource.
OwnerId string
The UUID of the Equinix Metal API User who owns this key.
Updated string
The timestamp for the last time the SSH key was updated.
created String
The timestamp for when the SSH key was created.
fingerprint String
The fingerprint of the SSH key.
id String
The provider-assigned unique ID for this managed resource.
ownerId String
The UUID of the Equinix Metal API User who owns this key.
updated String
The timestamp for the last time the SSH key was updated.
created string
The timestamp for when the SSH key was created.
fingerprint string
The fingerprint of the SSH key.
id string
The provider-assigned unique ID for this managed resource.
ownerId string
The UUID of the Equinix Metal API User who owns this key.
updated string
The timestamp for the last time the SSH key was updated.
created str
The timestamp for when the SSH key was created.
fingerprint str
The fingerprint of the SSH key.
id str
The provider-assigned unique ID for this managed resource.
owner_id str
The UUID of the Equinix Metal API User who owns this key.
updated str
The timestamp for the last time the SSH key was updated.
created String
The timestamp for when the SSH key was created.
fingerprint String
The fingerprint of the SSH key.
id String
The provider-assigned unique ID for this managed resource.
ownerId String
The UUID of the Equinix Metal API User who owns this key.
updated String
The timestamp for the last time the SSH key was updated.

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,
        fingerprint: Optional[str] = None,
        name: Optional[str] = None,
        owner_id: Optional[str] = None,
        public_key: Optional[str] = None,
        updated: 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)
resources:  _:    type: equinix:metal:SshKey    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 timestamp for when the SSH key was created.
Fingerprint string
The fingerprint of the SSH key.
Name string
The name of the SSH key for identification
OwnerId string
The UUID of the Equinix Metal API User who owns this key.
PublicKey string
The public key. If this is a file, it can be read using the file interpolation function
Updated string
The timestamp for the last time the SSH key was updated.
Created string
The timestamp for when the SSH key was created.
Fingerprint string
The fingerprint of the SSH key.
Name string
The name of the SSH key for identification
OwnerId string
The UUID of the Equinix Metal API User who owns this key.
PublicKey string
The public key. If this is a file, it can be read using the file interpolation function
Updated string
The timestamp for the last time the SSH key was updated.
created String
The timestamp for when the SSH key was created.
fingerprint String
The fingerprint of the SSH key.
name String
The name of the SSH key for identification
ownerId String
The UUID of the Equinix Metal API User who owns this key.
publicKey String
The public key. If this is a file, it can be read using the file interpolation function
updated String
The timestamp for the last time the SSH key was updated.
created string
The timestamp for when the SSH key was created.
fingerprint string
The fingerprint of the SSH key.
name string
The name of the SSH key for identification
ownerId string
The UUID of the Equinix Metal API User who owns this key.
publicKey string
The public key. If this is a file, it can be read using the file interpolation function
updated string
The timestamp for the last time the SSH key was updated.
created str
The timestamp for when the SSH key was created.
fingerprint str
The fingerprint of the SSH key.
name str
The name of the SSH key for identification
owner_id str
The UUID of the Equinix Metal API User who owns this key.
public_key str
The public key. If this is a file, it can be read using the file interpolation function
updated str
The timestamp for the last time the SSH key was updated.
created String
The timestamp for when the SSH key was created.
fingerprint String
The fingerprint of the SSH key.
name String
The name of the SSH key for identification
ownerId String
The UUID of the Equinix Metal API User who owns this key.
publicKey String
The public key. If this is a file, it can be read using the file interpolation function
updated String
The timestamp for the last time the SSH key was updated.

Package Details

Repository
equinix equinix/pulumi-equinix
License
Apache-2.0
Notes
This Pulumi package is based on the equinix Terraform Provider.