Hetzner Cloud v1.20.4 published on Tuesday, Sep 24, 2024 by Pulumi
hcloud.getSshKeys
Explore with Pulumi AI
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as hcloud from "@pulumi/hcloud";
const allKeys = hcloud.getSshKeys({});
const keysBySelector = hcloud.getSshKeys({
withSelector: "foo=bar",
});
const main = new hcloud.Server("main", {sshKeys: allKeys.then(allKeys => allKeys.sshKeys.map(__item => __item.name))});
import pulumi
import pulumi_hcloud as hcloud
all_keys = hcloud.get_ssh_keys()
keys_by_selector = hcloud.get_ssh_keys(with_selector="foo=bar")
main = hcloud.Server("main", ssh_keys=[__item.name for __item in all_keys.ssh_keys])
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 {
allKeys, err := hcloud.GetSshKeys(ctx, nil, 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 allKeys.SshKeys {
splat0 = append(splat0, val0.Name)
}
_, err = hcloud.NewServer(ctx, "main", &hcloud.ServerArgs{
SshKeys: splat0,
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using HCloud = Pulumi.HCloud;
return await Deployment.RunAsync(() =>
{
var allKeys = HCloud.GetSshKeys.Invoke();
var keysBySelector = HCloud.GetSshKeys.Invoke(new()
{
WithSelector = "foo=bar",
});
var main = new HCloud.Server("main", new()
{
SshKeys = allKeys.Apply(getSshKeysResult => getSshKeysResult.SshKeys).Select(__item => __item.Name).ToList(),
});
});
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 allKeys = HcloudFunctions.getSshKeys();
final var keysBySelector = HcloudFunctions.getSshKeys(GetSshKeysArgs.builder()
.withSelector("foo=bar")
.build());
var main = new Server("main", ServerArgs.builder()
.sshKeys(allKeys.applyValue(getSshKeysResult -> getSshKeysResult.sshKeys()).stream().map(element -> element.name()).collect(toList()))
.build());
}
}
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>
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]
func GetSshKeys(ctx *Context, args *GetSshKeysArgs, opts ...InvokeOption) (*GetSshKeysResult, error)
func GetSshKeysOutput(ctx *Context, args *GetSshKeysOutputArgs, opts ...InvokeOption) GetSshKeysResultOutput
> 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)
}
public static CompletableFuture<GetSshKeysResult> getSshKeys(GetSshKeysArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
function: hcloud:index/getSshKeys:getSshKeys
arguments:
# arguments dictionary
The following arguments are supported:
- Id string
- With
Selector string - Label selector
- Id string
- With
Selector string - Label selector
- id String
- with
Selector String - Label selector
- id string
- with
Selector string - Label selector
- id str
- with_
selector str - Label selector
- id String
- with
Selector String - Label selector
getSshKeys Result
The following output properties are available:
- Ssh
Keys List<Pulumi.HCloud. Outputs. Get Ssh Keys Ssh Key> - (list) List of all matches SSH keys. See
data.hcloud_ssh_key
for schema. - Id string
- With
Selector string
- Ssh
Keys []GetSsh Keys Ssh Key - (list) List of all matches SSH keys. See
data.hcloud_ssh_key
for schema. - Id string
- With
Selector string
- ssh
Keys List<GetSsh Keys Ssh Key> - (list) List of all matches SSH keys. See
data.hcloud_ssh_key
for schema. - id String
- with
Selector String
- ssh
Keys GetSsh Keys Ssh Key[] - (list) List of all matches SSH keys. See
data.hcloud_ssh_key
for schema. - id string
- with
Selector string
- ssh_
keys Sequence[GetSsh Keys Ssh Key] - (list) List of all matches SSH keys. See
data.hcloud_ssh_key
for schema. - id str
- with_
selector str
- ssh
Keys List<Property Map> - (list) List of all matches SSH keys. See
data.hcloud_ssh_key
for schema. - id String
- with
Selector String
Supporting Types
GetSshKeysSshKey
- fingerprint str
- Fingerprint of the SSH key.
- id int
- ID of the SSH key.
- labels Mapping[str, str]
- User-defined labels (key-value pairs) for the resource.
- name str
- Name of the SSH key.
- public_
key str - 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.