1. Packages
  2. Hcloud Provider
  3. API Docs
  4. getSshKeys
Hetzner Cloud v1.22.0 published on Wednesday, Feb 26, 2025 by Pulumi

hcloud.getSshKeys

Explore with Pulumi AI

Hetzner Cloud v1.22.0 published on Wednesday, Feb 26, 2025 by Pulumi

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as hcloud from "@pulumi/hcloud";

const all = hcloud.getSshKeys({});
const byLabel = hcloud.getSshKeys({
    withSelector: "foo=bar",
});
const main = new hcloud.Server("main", {sshKeys: all.then(all => all.sshKeys.map(__item => __item.name))});
Copy
import pulumi
import pulumi_hcloud as hcloud

all = hcloud.get_ssh_keys()
by_label = hcloud.get_ssh_keys(with_selector="foo=bar")
main = hcloud.Server("main", ssh_keys=[__item.name for __item in all.ssh_keys])
Copy
package main

import (
	"github.com/pulumi/pulumi-hcloud/sdk/go/hcloud"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		all, err := hcloud.GetSshKeys(ctx, &hcloud.GetSshKeysArgs{}, nil)
		if err != nil {
			return err
		}
		_, err = hcloud.GetSshKeys(ctx, &hcloud.GetSshKeysArgs{
			WithSelector: pulumi.StringRef("foo=bar"),
		}, nil)
		if err != nil {
			return err
		}
		var splat0 []*string
		for _, val0 := range all.SshKeys {
			splat0 = append(splat0, val0.Name)
		}
		_, err = hcloud.NewServer(ctx, "main", &hcloud.ServerArgs{
			SshKeys: splat0,
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using HCloud = Pulumi.HCloud;

return await Deployment.RunAsync(() => 
{
    var all = HCloud.GetSshKeys.Invoke();

    var byLabel = HCloud.GetSshKeys.Invoke(new()
    {
        WithSelector = "foo=bar",
    });

    var main = new HCloud.Server("main", new()
    {
        SshKeys = all.Apply(getSshKeysResult => getSshKeysResult.SshKeys).Select(__item => __item.Name).ToList(),
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.hcloud.HcloudFunctions;
import com.pulumi.hcloud.inputs.GetSshKeysArgs;
import com.pulumi.hcloud.Server;
import com.pulumi.hcloud.ServerArgs;
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 all = HcloudFunctions.getSshKeys();

        final var byLabel = HcloudFunctions.getSshKeys(GetSshKeysArgs.builder()
            .withSelector("foo=bar")
            .build());

        var main = new Server("main", ServerArgs.builder()
            .sshKeys(all.applyValue(getSshKeysResult -> getSshKeysResult.sshKeys()).stream().map(element -> element.name()).collect(toList()))
            .build());

    }
}
Copy
Coming soon!

Using getSshKeys

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getSshKeys(args: GetSshKeysArgs, opts?: InvokeOptions): Promise<GetSshKeysResult>
function getSshKeysOutput(args: GetSshKeysOutputArgs, opts?: InvokeOptions): Output<GetSshKeysResult>
Copy
def get_ssh_keys(id: Optional[str] = None,
                 with_selector: Optional[str] = None,
                 opts: Optional[InvokeOptions] = None) -> GetSshKeysResult
def get_ssh_keys_output(id: Optional[pulumi.Input[str]] = None,
                 with_selector: Optional[pulumi.Input[str]] = None,
                 opts: Optional[InvokeOptions] = None) -> Output[GetSshKeysResult]
Copy
func GetSshKeys(ctx *Context, args *GetSshKeysArgs, opts ...InvokeOption) (*GetSshKeysResult, error)
func GetSshKeysOutput(ctx *Context, args *GetSshKeysOutputArgs, opts ...InvokeOption) GetSshKeysResultOutput
Copy

> Note: This function is named GetSshKeys in the Go SDK.

public static class GetSshKeys 
{
    public static Task<GetSshKeysResult> InvokeAsync(GetSshKeysArgs args, InvokeOptions? opts = null)
    public static Output<GetSshKeysResult> Invoke(GetSshKeysInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetSshKeysResult> getSshKeys(GetSshKeysArgs args, InvokeOptions options)
public static Output<GetSshKeysResult> getSshKeys(GetSshKeysArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: hcloud:index/getSshKeys:getSshKeys
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Id string
The ID of this resource.
WithSelector string
Filter results using a Label Selector
Id string
The ID of this resource.
WithSelector string
Filter results using a Label Selector
id String
The ID of this resource.
withSelector String
Filter results using a Label Selector
id string
The ID of this resource.
withSelector string
Filter results using a Label Selector
id str
The ID of this resource.
with_selector str
Filter results using a Label Selector
id String
The ID of this resource.
withSelector String
Filter results using a Label Selector

getSshKeys Result

The following output properties are available:

SshKeys List<Pulumi.HCloud.Outputs.GetSshKeysSshKey>
Id string
The ID of this resource.
WithSelector string
Filter results using a Label Selector
SshKeys []GetSshKeysSshKey
Id string
The ID of this resource.
WithSelector string
Filter results using a Label Selector
sshKeys List<GetSshKeysSshKey>
id String
The ID of this resource.
withSelector String
Filter results using a Label Selector
sshKeys GetSshKeysSshKey[]
id string
The ID of this resource.
withSelector string
Filter results using a Label Selector
ssh_keys Sequence[GetSshKeysSshKey]
id str
The ID of this resource.
with_selector str
Filter results using a Label Selector
sshKeys List<Property Map>
id String
The ID of this resource.
withSelector String
Filter results using a Label Selector

Supporting Types

GetSshKeysSshKey

Fingerprint This property is required. string
Fingerprint of the SSH Key.
Id This property is required. int
ID of the SSH Key.
Labels This property is required. Dictionary<string, string>
User-defined labels (key-value pairs) for the resource.
Name This property is required. string
Name of the SSH Key.
PublicKey This property is required. string
Public key of the SSH Key pair.
Fingerprint This property is required. string
Fingerprint of the SSH Key.
Id This property is required. int
ID of the SSH Key.
Labels This property is required. map[string]string
User-defined labels (key-value pairs) for the resource.
Name This property is required. string
Name of the SSH Key.
PublicKey This property is required. string
Public key of the SSH Key pair.
fingerprint This property is required. String
Fingerprint of the SSH Key.
id This property is required. Integer
ID of the SSH Key.
labels This property is required. Map<String,String>
User-defined labels (key-value pairs) for the resource.
name This property is required. String
Name of the SSH Key.
publicKey This property is required. String
Public key of the SSH Key pair.
fingerprint This property is required. string
Fingerprint of the SSH Key.
id This property is required. number
ID of the SSH Key.
labels This property is required. {[key: string]: string}
User-defined labels (key-value pairs) for the resource.
name This property is required. string
Name of the SSH Key.
publicKey This property is required. string
Public key of the SSH Key pair.
fingerprint This property is required. str
Fingerprint of the SSH Key.
id This property is required. int
ID of the SSH Key.
labels This property is required. Mapping[str, str]
User-defined labels (key-value pairs) for the resource.
name This property is required. str
Name of the SSH Key.
public_key This property is required. str
Public key of the SSH Key pair.
fingerprint This property is required. String
Fingerprint of the SSH Key.
id This property is required. Number
ID of the SSH Key.
labels This property is required. Map<String>
User-defined labels (key-value pairs) for the resource.
name This property is required. String
Name of the SSH Key.
publicKey This property is required. String
Public key of the SSH Key pair.

Package Details

Repository
Hetzner Cloud pulumi/pulumi-hcloud
License
Apache-2.0
Notes
This Pulumi package is based on the hcloud Terraform Provider.
Hetzner Cloud v1.22.0 published on Wednesday, Feb 26, 2025 by Pulumi