Hetzner Cloud v1.21.1 published on Friday, Nov 22, 2024 by Pulumi
hcloud.getSshKey
Explore with Pulumi AI
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as hcloud from "@pulumi/hcloud";
const byId = hcloud.getSshKey({
id: 24332897,
});
const byName = hcloud.getSshKey({
name: "my-ssh-key",
});
const byFingerprint = hcloud.getSshKey({
fingerprint: "55:58:dc:bd:61:6e:7d:24:07:a7:7d:9b:be:99:83:a8",
});
const byLabel = hcloud.getSshKey({
withSelector: "key=value",
});
const main = new hcloud.Server("main", {sshKeys: [
byId.then(byId => byId.id),
byName.then(byName => byName.id),
byFingerprint.then(byFingerprint => byFingerprint.id),
]});
import pulumi
import pulumi_hcloud as hcloud
by_id = hcloud.get_ssh_key(id=24332897)
by_name = hcloud.get_ssh_key(name="my-ssh-key")
by_fingerprint = hcloud.get_ssh_key(fingerprint="55:58:dc:bd:61:6e:7d:24:07:a7:7d:9b:be:99:83:a8")
by_label = hcloud.get_ssh_key(with_selector="key=value")
main = hcloud.Server("main", ssh_keys=[
by_id.id,
by_name.id,
by_fingerprint.id,
])
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 {
byId, err := hcloud.LookupSshKey(ctx, &hcloud.LookupSshKeyArgs{
Id: pulumi.IntRef(24332897),
}, nil)
if err != nil {
return err
}
byName, err := hcloud.LookupSshKey(ctx, &hcloud.LookupSshKeyArgs{
Name: pulumi.StringRef("my-ssh-key"),
}, nil)
if err != nil {
return err
}
byFingerprint, err := hcloud.LookupSshKey(ctx, &hcloud.LookupSshKeyArgs{
Fingerprint: pulumi.StringRef("55:58:dc:bd:61:6e:7d:24:07:a7:7d:9b:be:99:83:a8"),
}, nil)
if err != nil {
return err
}
_, err = hcloud.LookupSshKey(ctx, &hcloud.LookupSshKeyArgs{
WithSelector: pulumi.StringRef("key=value"),
}, nil)
if err != nil {
return err
}
_, err = hcloud.NewServer(ctx, "main", &hcloud.ServerArgs{
SshKeys: pulumi.StringArray{
pulumi.Int(byId.Id),
pulumi.Int(byName.Id),
pulumi.Int(byFingerprint.Id),
},
})
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 byId = HCloud.GetSshKey.Invoke(new()
{
Id = 24332897,
});
var byName = HCloud.GetSshKey.Invoke(new()
{
Name = "my-ssh-key",
});
var byFingerprint = HCloud.GetSshKey.Invoke(new()
{
Fingerprint = "55:58:dc:bd:61:6e:7d:24:07:a7:7d:9b:be:99:83:a8",
});
var byLabel = HCloud.GetSshKey.Invoke(new()
{
WithSelector = "key=value",
});
var main = new HCloud.Server("main", new()
{
SshKeys = new[]
{
byId.Apply(getSshKeyResult => getSshKeyResult.Id),
byName.Apply(getSshKeyResult => getSshKeyResult.Id),
byFingerprint.Apply(getSshKeyResult => getSshKeyResult.Id),
},
});
});
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.GetSshKeyArgs;
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 byId = HcloudFunctions.getSshKey(GetSshKeyArgs.builder()
.id(24332897)
.build());
final var byName = HcloudFunctions.getSshKey(GetSshKeyArgs.builder()
.name("my-ssh-key")
.build());
final var byFingerprint = HcloudFunctions.getSshKey(GetSshKeyArgs.builder()
.fingerprint("55:58:dc:bd:61:6e:7d:24:07:a7:7d:9b:be:99:83:a8")
.build());
final var byLabel = HcloudFunctions.getSshKey(GetSshKeyArgs.builder()
.withSelector("key=value")
.build());
var main = new Server("main", ServerArgs.builder()
.sshKeys(
byId.applyValue(getSshKeyResult -> getSshKeyResult.id()),
byName.applyValue(getSshKeyResult -> getSshKeyResult.id()),
byFingerprint.applyValue(getSshKeyResult -> getSshKeyResult.id()))
.build());
}
}
resources:
main:
type: hcloud:Server
properties:
sshKeys:
- ${byId.id}
- ${byName.id}
- ${byFingerprint.id}
variables:
byId:
fn::invoke:
Function: hcloud:getSshKey
Arguments:
id: 2.4332897e+07
byName:
fn::invoke:
Function: hcloud:getSshKey
Arguments:
name: my-ssh-key
byFingerprint:
fn::invoke:
Function: hcloud:getSshKey
Arguments:
fingerprint: 55:58:dc:bd:61:6e:7d:24:07:a7:7d:9b:be:99:83:a8
byLabel:
fn::invoke:
Function: hcloud:getSshKey
Arguments:
withSelector: key=value
Using getSshKey
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 getSshKey(args: GetSshKeyArgs, opts?: InvokeOptions): Promise<GetSshKeyResult>
function getSshKeyOutput(args: GetSshKeyOutputArgs, opts?: InvokeOptions): Output<GetSshKeyResult>
def get_ssh_key(fingerprint: Optional[str] = None,
id: Optional[int] = None,
name: Optional[str] = None,
selector: Optional[str] = None,
with_selector: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetSshKeyResult
def get_ssh_key_output(fingerprint: Optional[pulumi.Input[str]] = None,
id: Optional[pulumi.Input[int]] = None,
name: Optional[pulumi.Input[str]] = None,
selector: Optional[pulumi.Input[str]] = None,
with_selector: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetSshKeyResult]
func LookupSshKey(ctx *Context, args *LookupSshKeyArgs, opts ...InvokeOption) (*LookupSshKeyResult, error)
func LookupSshKeyOutput(ctx *Context, args *LookupSshKeyOutputArgs, opts ...InvokeOption) LookupSshKeyResultOutput
> Note: This function is named LookupSshKey
in the Go SDK.
public static class GetSshKey
{
public static Task<GetSshKeyResult> InvokeAsync(GetSshKeyArgs args, InvokeOptions? opts = null)
public static Output<GetSshKeyResult> Invoke(GetSshKeyInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetSshKeyResult> getSshKey(GetSshKeyArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
function: hcloud:index/getSshKey:getSshKey
arguments:
# arguments dictionary
The following arguments are supported:
- Fingerprint string
- Fingerprint of the SSH Key.
- Id int
- ID of the SSH Key.
- Name string
- Name of the SSH Key.
- Selector string
- Filter results using a Label Selector.
- With
Selector string - Filter results using a Label Selector.
- Fingerprint string
- Fingerprint of the SSH Key.
- Id int
- ID of the SSH Key.
- Name string
- Name of the SSH Key.
- Selector string
- Filter results using a Label Selector.
- With
Selector string - Filter results using a Label Selector.
- fingerprint String
- Fingerprint of the SSH Key.
- id Integer
- ID of the SSH Key.
- name String
- Name of the SSH Key.
- selector String
- Filter results using a Label Selector.
- with
Selector String - Filter results using a Label Selector.
- fingerprint string
- Fingerprint of the SSH Key.
- id number
- ID of the SSH Key.
- name string
- Name of the SSH Key.
- selector string
- Filter results using a Label Selector.
- with
Selector string - Filter results using a Label Selector.
- fingerprint str
- Fingerprint of the SSH Key.
- id int
- ID of the SSH Key.
- name str
- Name of the SSH Key.
- selector str
- Filter results using a Label Selector.
- with_
selector str - Filter results using a Label Selector.
- fingerprint String
- Fingerprint of the SSH Key.
- id Number
- ID of the SSH Key.
- name String
- Name of the SSH Key.
- selector String
- Filter results using a Label Selector.
- with
Selector String - Filter results using a Label Selector.
getSshKey Result
The following output properties are available:
- Labels Dictionary<string, string>
- User-defined labels (key-value pairs) for the resource.
- Public
Key string - Public key of the SSH Key pair.
- Fingerprint string
- Fingerprint of the SSH Key.
- Id int
- ID of the SSH Key.
- Name string
- Name of the SSH Key.
- Selector string
- Filter results using a Label Selector.
- With
Selector string - Filter results using a Label Selector.
- Labels map[string]string
- User-defined labels (key-value pairs) for the resource.
- Public
Key string - Public key of the SSH Key pair.
- Fingerprint string
- Fingerprint of the SSH Key.
- Id int
- ID of the SSH Key.
- Name string
- Name of the SSH Key.
- Selector string
- Filter results using a Label Selector.
- With
Selector string - Filter results using a Label Selector.
- labels Map<String,String>
- User-defined labels (key-value pairs) for the resource.
- public
Key String - Public key of the SSH Key pair.
- fingerprint String
- Fingerprint of the SSH Key.
- id Integer
- ID of the SSH Key.
- name String
- Name of the SSH Key.
- selector String
- Filter results using a Label Selector.
- with
Selector String - Filter results using a Label Selector.
- labels {[key: string]: string}
- User-defined labels (key-value pairs) for the resource.
- public
Key string - Public key of the SSH Key pair.
- fingerprint string
- Fingerprint of the SSH Key.
- id number
- ID of the SSH Key.
- name string
- Name of the SSH Key.
- selector string
- Filter results using a Label Selector.
- with
Selector string - Filter results using a Label Selector.
- labels Mapping[str, str]
- User-defined labels (key-value pairs) for the resource.
- public_
key str - Public key of the SSH Key pair.
- fingerprint str
- Fingerprint of the SSH Key.
- id int
- ID of the SSH Key.
- name str
- Name of the SSH Key.
- selector str
- Filter results using a Label Selector.
- with_
selector str - Filter results using a Label Selector.
- labels Map<String>
- User-defined labels (key-value pairs) for the resource.
- public
Key String - Public key of the SSH Key pair.
- fingerprint String
- Fingerprint of the SSH Key.
- id Number
- ID of the SSH Key.
- name String
- Name of the SSH Key.
- selector String
- Filter results using a Label Selector.
- with
Selector String - Filter results using a Label Selector.
Package Details
- Repository
- Hetzner Cloud pulumi/pulumi-hcloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
hcloud
Terraform Provider.