1. Packages
  2. Digitalocean Provider
  3. API Docs
  4. getSshKeys
DigitalOcean v4.35.0 published on Tuesday, Nov 19, 2024 by Pulumi

digitalocean.getSshKeys

Explore with Pulumi AI

digitalocean logo
DigitalOcean v4.35.0 published on Tuesday, Nov 19, 2024 by Pulumi

    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.DigitalOcean.Inputs.GetSshKeysFilter>
    Filter the results. The filter block is documented below.
    Sorts List<Pulumi.DigitalOcean.Inputs.GetSshKeysSort>
    Sort the results. The sort block is documented below.
    Filters []GetSshKeysFilter
    Filter the results. The filter block is documented below.
    Sorts []GetSshKeysSort
    Sort the results. The sort block is documented below.
    filters List<GetSshKeysFilter>
    Filter the results. The filter block is documented below.
    sorts List<GetSshKeysSort>
    Sort the results. The sort block is documented below.
    filters GetSshKeysFilter[]
    Filter the results. The filter block is documented below.
    sorts GetSshKeysSort[]
    Sort the results. The sort block is documented below.
    filters Sequence[GetSshKeysFilter]
    Filter the results. The filter block is documented below.
    sorts Sequence[GetSshKeysSort]
    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.
    SshKeys List<Pulumi.DigitalOcean.Outputs.GetSshKeysSshKey>
    A list of SSH Keys. Each SSH Key has the following attributes:
    Filters List<Pulumi.DigitalOcean.Outputs.GetSshKeysFilter>
    Sorts List<Pulumi.DigitalOcean.Outputs.GetSshKeysSort>
    Id string
    The provider-assigned unique ID for this managed resource.
    SshKeys []GetSshKeysSshKey
    A list of SSH Keys. Each SSH Key has the following attributes:
    Filters []GetSshKeysFilter
    Sorts []GetSshKeysSort
    id String
    The provider-assigned unique ID for this managed resource.
    sshKeys List<GetSshKeysSshKey>
    A list of SSH Keys. Each SSH Key has the following attributes:
    filters List<GetSshKeysFilter>
    sorts List<GetSshKeysSort>
    id string
    The provider-assigned unique ID for this managed resource.
    sshKeys GetSshKeysSshKey[]
    A list of SSH Keys. Each SSH Key has the following attributes:
    filters GetSshKeysFilter[]
    sorts GetSshKeysSort[]
    id str
    The provider-assigned unique ID for this managed resource.
    ssh_keys Sequence[GetSshKeysSshKey]
    A list of SSH Keys. Each SSH Key has the following attributes:
    filters Sequence[GetSshKeysFilter]
    sorts Sequence[GetSshKeysSort]
    id String
    The provider-assigned unique ID for this managed resource.
    sshKeys 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

    Key string
    Filter the SSH Keys by this key. This may be one of name, public_key, or fingerprint.
    Values List<string>
    A list of values to match against the key field. Only retrieves SSH keys where the key field matches one or more of the values provided here.
    All bool
    MatchBy string
    Key string
    Filter the SSH Keys by this key. This may be one of name, public_key, or fingerprint.
    Values []string
    A list of values to match against the key field. Only retrieves SSH keys where the key field matches one or more of the values provided here.
    All bool
    MatchBy string
    key String
    Filter the SSH Keys by this key. This may be one of name, public_key, or fingerprint.
    values List<String>
    A list of values to match against the key field. Only retrieves SSH keys where the key field matches one or more of the values provided here.
    all Boolean
    matchBy String
    key string
    Filter the SSH Keys by this key. This may be one of name, public_key, or fingerprint.
    values string[]
    A list of values to match against the key field. Only retrieves SSH keys where the key field matches one or more of the values provided here.
    all boolean
    matchBy string
    key str
    Filter the SSH Keys by this key. This may be one of name, public_key, or fingerprint.
    values Sequence[str]
    A list of values to match against the key field. Only retrieves SSH keys where the key field matches one or more of the values provided here.
    all bool
    match_by str
    key String
    Filter the SSH Keys by this key. This may be one of name, public_key, or fingerprint.
    values List<String>
    A list of values to match against the key field. Only retrieves SSH keys where the key field matches one or more of the values provided here.
    all Boolean
    matchBy String

    GetSshKeysSort

    Key string
    Sort the SSH Keys by this key. This may be one of name, public_key, or fingerprint.
    Direction string
    The sort direction. This may be either asc or desc.
    Key string
    Sort the SSH Keys by this key. This may be one of name, public_key, or fingerprint.
    Direction string
    The sort direction. This may be either asc or desc.
    key String
    Sort the SSH Keys by this key. This may be one of name, public_key, or fingerprint.
    direction String
    The sort direction. This may be either asc or desc.
    key string
    Sort the SSH Keys by this key. This may be one of name, public_key, or fingerprint.
    direction string
    The sort direction. This may be either asc or desc.
    key str
    Sort the SSH Keys by this key. This may be one of name, public_key, or fingerprint.
    direction str
    The sort direction. This may be either asc or desc.
    key String
    Sort the SSH Keys by this key. This may be one of name, public_key, or fingerprint.
    direction String
    The sort direction. This may be either asc or desc.

    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.
    PublicKey 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.
    PublicKey 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.
    publicKey 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.
    publicKey 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.
    publicKey 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.
    digitalocean logo
    DigitalOcean v4.35.0 published on Tuesday, Nov 19, 2024 by Pulumi