digitalocean.getSshKey
Explore with Pulumi AI
Get information on a ssh key. This data source provides the name, public key, and fingerprint as configured on your DigitalOcean account. This is useful if the ssh key in question is not managed by the provider or you need to utilize any of the keys data.
An error is triggered if the provided ssh key name does not exist.
Example Usage
Get the ssh key:
import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";
const example = digitalocean.getSshKey({
name: "example",
});
const exampleDroplet = new digitalocean.Droplet("example", {
image: "ubuntu-18-04-x64",
name: "example-1",
region: digitalocean.Region.NYC2,
size: digitalocean.DropletSlug.DropletS1VCPU1GB,
sshKeys: [example.then(example => example.id)],
});
import pulumi
import pulumi_digitalocean as digitalocean
example = digitalocean.get_ssh_key(name="example")
example_droplet = digitalocean.Droplet("example",
image="ubuntu-18-04-x64",
name="example-1",
region=digitalocean.Region.NYC2,
size=digitalocean.DropletSlug.DROPLET_S1_VCPU1_GB,
ssh_keys=[example.id])
package main
import (
"github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := digitalocean.LookupSshKey(ctx, &digitalocean.LookupSshKeyArgs{
Name: "example",
}, nil)
if err != nil {
return err
}
_, err = digitalocean.NewDroplet(ctx, "example", &digitalocean.DropletArgs{
Image: pulumi.String("ubuntu-18-04-x64"),
Name: pulumi.String("example-1"),
Region: pulumi.String(digitalocean.RegionNYC2),
Size: pulumi.String(digitalocean.DropletSlugDropletS1VCPU1GB),
SshKeys: pulumi.StringArray{
pulumi.Int(example.Id),
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;
return await Deployment.RunAsync(() =>
{
var example = DigitalOcean.GetSshKey.Invoke(new()
{
Name = "example",
});
var exampleDroplet = new DigitalOcean.Droplet("example", new()
{
Image = "ubuntu-18-04-x64",
Name = "example-1",
Region = DigitalOcean.Region.NYC2,
Size = DigitalOcean.DropletSlug.DropletS1VCPU1GB,
SshKeys = new[]
{
example.Apply(getSshKeyResult => getSshKeyResult.Id),
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.digitalocean.DigitaloceanFunctions;
import com.pulumi.digitalocean.inputs.GetSshKeyArgs;
import com.pulumi.digitalocean.Droplet;
import com.pulumi.digitalocean.DropletArgs;
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 example = DigitaloceanFunctions.getSshKey(GetSshKeyArgs.builder()
.name("example")
.build());
var exampleDroplet = new Droplet("exampleDroplet", DropletArgs.builder()
.image("ubuntu-18-04-x64")
.name("example-1")
.region("nyc2")
.size("s-1vcpu-1gb")
.sshKeys(example.applyValue(getSshKeyResult -> getSshKeyResult.id()))
.build());
}
}
resources:
exampleDroplet:
type: digitalocean:Droplet
name: example
properties:
image: ubuntu-18-04-x64
name: example-1
region: nyc2
size: s-1vcpu-1gb
sshKeys:
- ${example.id}
variables:
example:
fn::invoke:
Function: digitalocean:getSshKey
Arguments:
name: example
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(name: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetSshKeyResult
def get_ssh_key_output(name: 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: digitalocean:index/getSshKey:getSshKey
arguments:
# arguments dictionary
The following arguments are supported:
- Name string
- The name of the ssh key.
- Name string
- The name of the ssh key.
- name String
- The name of the ssh key.
- name string
- The name of the ssh key.
- name str
- The name of the ssh key.
- name String
- The name of the ssh key.
getSshKey Result
The following output properties are available:
- Fingerprint string
- The fingerprint of the public key of the ssh key.
- Id int
- The ID of the ssh key.
- Name string
- Public
Key string - The public key of the ssh key.
- Fingerprint string
- The fingerprint of the public key of the ssh key.
- Id int
- The ID of the ssh key.
- Name string
- Public
Key string - The public key of the ssh key.
- fingerprint String
- The fingerprint of the public key of the ssh key.
- id Integer
- The ID of the ssh key.
- name String
- public
Key String - The public key of the ssh key.
- fingerprint string
- The fingerprint of the public key of the ssh key.
- id number
- The ID of the ssh key.
- name string
- public
Key string - The public key of the ssh key.
- fingerprint str
- The fingerprint of the public key of the ssh key.
- id int
- The ID of the ssh key.
- name str
- public_
key str - The public key of the ssh key.
- fingerprint String
- The fingerprint of the public key of the ssh key.
- id Number
- The ID of the ssh key.
- name String
- public
Key String - The public key of the ssh key.
Package Details
- Repository
- DigitalOcean pulumi/pulumi-digitalocean
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
digitalocean
Terraform Provider.