digitalocean.getSshKeys
Explore with Pulumi AI
Get information on SSH Keys for use in other resources.
This data source is useful if the SSH Keys in question are not managed by the provider or you need to utilize any of the SSH Keys’ data.
Note: You can use the digitalocean.SshKey
data source to obtain metadata
about a single SSH Key if you already know the unique name
to retrieve.
Example Usage
For example, to find all SSH keys:
import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";
const keys = digitalocean.getSshKeys({
sorts: [{
key: "name",
direction: "asc",
}],
});
import pulumi
import pulumi_digitalocean as digitalocean
keys = digitalocean.get_ssh_keys(sorts=[{
"key": "name",
"direction": "asc",
}])
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 {
_, err := digitalocean.GetSshKeys(ctx, &digitalocean.GetSshKeysArgs{
Sorts: []digitalocean.GetSshKeysSort{
{
Key: "name",
Direction: pulumi.StringRef("asc"),
},
},
}, nil)
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 keys = DigitalOcean.GetSshKeys.Invoke(new()
{
Sorts = new[]
{
new DigitalOcean.Inputs.GetSshKeysSortInputArgs
{
Key = "name",
Direction = "asc",
},
},
});
});
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.GetSshKeysArgs;
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 keys = DigitaloceanFunctions.getSshKeys(GetSshKeysArgs.builder()
.sorts(GetSshKeysSortArgs.builder()
.key("name")
.direction("asc")
.build())
.build());
}
}
variables:
keys:
fn::invoke:
Function: digitalocean:getSshKeys
Arguments:
sorts:
- key: name
direction: asc
Or to find ones matching specific values:
import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";
const keys = digitalocean.getSshKeys({
filters: [{
key: "name",
values: [
"laptop",
"desktop",
],
}],
});
import pulumi
import pulumi_digitalocean as digitalocean
keys = digitalocean.get_ssh_keys(filters=[{
"key": "name",
"values": [
"laptop",
"desktop",
],
}])
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 {
_, err := digitalocean.GetSshKeys(ctx, &digitalocean.GetSshKeysArgs{
Filters: []digitalocean.GetSshKeysFilter{
{
Key: "name",
Values: []string{
"laptop",
"desktop",
},
},
},
}, nil)
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 keys = DigitalOcean.GetSshKeys.Invoke(new()
{
Filters = new[]
{
new DigitalOcean.Inputs.GetSshKeysFilterInputArgs
{
Key = "name",
Values = new[]
{
"laptop",
"desktop",
},
},
},
});
});
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.GetSshKeysArgs;
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 keys = DigitaloceanFunctions.getSshKeys(GetSshKeysArgs.builder()
.filters(GetSshKeysFilterArgs.builder()
.key("name")
.values(
"laptop",
"desktop")
.build())
.build());
}
}
variables:
keys:
fn::invoke:
Function: digitalocean:getSshKeys
Arguments:
filters:
- key: name
values:
- laptop
- desktop
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(filters: Optional[Sequence[GetSshKeysFilter]] = None,
sorts: Optional[Sequence[GetSshKeysSort]] = None,
opts: Optional[InvokeOptions] = None) -> GetSshKeysResult
def get_ssh_keys_output(filters: Optional[pulumi.Input[Sequence[pulumi.Input[GetSshKeysFilterArgs]]]] = None,
sorts: Optional[pulumi.Input[Sequence[pulumi.Input[GetSshKeysSortArgs]]]] = 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: digitalocean:index/getSshKeys:getSshKeys
arguments:
# arguments dictionary
The following arguments are supported:
- Filters
List<Pulumi.
Digital Ocean. Inputs. Get Ssh Keys Filter> - Filter the results.
The
filter
block is documented below. - Sorts
List<Pulumi.
Digital Ocean. Inputs. Get Ssh Keys Sort> - Sort the results.
The
sort
block is documented below.
- Filters
[]Get
Ssh Keys Filter - Filter the results.
The
filter
block is documented below. - Sorts
[]Get
Ssh Keys Sort - Sort the results.
The
sort
block is documented below.
- filters
List<Get
Ssh Keys Filter> - Filter the results.
The
filter
block is documented below. - sorts
List<Get
Ssh Keys Sort> - Sort the results.
The
sort
block is documented below.
- filters
Get
Ssh Keys Filter[] - Filter the results.
The
filter
block is documented below. - sorts
Get
Ssh Keys Sort[] - Sort the results.
The
sort
block is documented below.
- filters
Sequence[Get
Ssh Keys Filter] - Filter the results.
The
filter
block is documented below. - sorts
Sequence[Get
Ssh Keys Sort] - Sort the results.
The
sort
block is documented below.
- filters List<Property Map>
- Filter the results.
The
filter
block is documented below. - sorts List<Property Map>
- Sort the results.
The
sort
block is documented below.
getSshKeys Result
The following output properties are available:
- Id string
- The provider-assigned unique ID for this managed resource.
- Ssh
Keys List<Pulumi.Digital Ocean. Outputs. Get Ssh Keys Ssh Key> - A list of SSH Keys. Each SSH Key has the following attributes:
- Filters
List<Pulumi.
Digital Ocean. Outputs. Get Ssh Keys Filter> - Sorts
List<Pulumi.
Digital Ocean. Outputs. Get Ssh Keys Sort>
- Id string
- The provider-assigned unique ID for this managed resource.
- Ssh
Keys []GetSsh Keys Ssh Key - A list of SSH Keys. Each SSH Key has the following attributes:
- Filters
[]Get
Ssh Keys Filter - Sorts
[]Get
Ssh Keys Sort
- id String
- The provider-assigned unique ID for this managed resource.
- ssh
Keys List<GetSsh Keys Ssh Key> - A list of SSH Keys. Each SSH Key has the following attributes:
- filters
List<Get
Ssh Keys Filter> - sorts
List<Get
Ssh Keys Sort>
- id string
- The provider-assigned unique ID for this managed resource.
- ssh
Keys GetSsh Keys Ssh Key[] - A list of SSH Keys. Each SSH Key has the following attributes:
- filters
Get
Ssh Keys Filter[] - sorts
Get
Ssh Keys Sort[]
- id str
- The provider-assigned unique ID for this managed resource.
- ssh_
keys Sequence[GetSsh Keys Ssh Key] - A list of SSH Keys. Each SSH Key has the following attributes:
- filters
Sequence[Get
Ssh Keys Filter] - sorts
Sequence[Get
Ssh Keys Sort]
- id String
- The provider-assigned unique ID for this managed resource.
- ssh
Keys List<Property Map> - A list of SSH Keys. Each SSH Key has the following attributes:
- filters List<Property Map>
- sorts List<Property Map>
Supporting Types
GetSshKeysFilter
GetSshKeysSort
GetSshKeysSshKey
- Fingerprint string
- The fingerprint of the public key of the ssh key.
- Id int
- The ID of the ssh key.
- Name string
- The name of the ssh key.
- 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
- The name of the ssh key.
- 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
- The name of the ssh key.
- 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
- The name of the ssh key.
- 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
- The name of the ssh key.
- 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
- The name of the ssh key.
- 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.