ibm.getComputeSshKey
Explore with Pulumi AI
Retrieve information of an existing SSH key as a read-only data source. For more information, about computer SSH key, see deploying server pools and origins in a single MZR.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as ibm from "@pulumi/ibm";
const publicKey = ibm.getComputeSshKey({
label: "Terraform Public Key",
});
import pulumi
import pulumi_ibm as ibm
public_key = ibm.get_compute_ssh_key(label="Terraform Public Key")
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/ibm/ibm"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := ibm.LookupComputeSshKey(ctx, &ibm.LookupComputeSshKeyArgs{
Label: "Terraform Public Key",
}, nil)
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Ibm = Pulumi.Ibm;
return await Deployment.RunAsync(() =>
{
var publicKey = Ibm.GetComputeSshKey.Invoke(new()
{
Label = "Terraform Public Key",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.ibm.IbmFunctions;
import com.pulumi.ibm.inputs.GetComputeSshKeyArgs;
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 publicKey = IbmFunctions.getComputeSshKey(GetComputeSshKeyArgs.builder()
.label("Terraform Public Key")
.build());
}
}
variables:
publicKey:
fn::invoke:
function: ibm:getComputeSshKey
arguments:
label: Terraform Public Key
The following example shows how you can use this data source to reference the SSH key IDs in the ibm.ComputeVmInstance
resource because the numeric IDs are often unknown.
import * as pulumi from "@pulumi/pulumi";
import * as ibm from "@pulumi/ibm";
const vm1 = new ibm.ComputeVmInstance("vm1", {sshKeyIds: [data.ibm_compute_ssh_key.public_key.id]});
import pulumi
import pulumi_ibm as ibm
vm1 = ibm.ComputeVmInstance("vm1", ssh_key_ids=[data["ibm_compute_ssh_key"]["public_key"]["id"]])
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/ibm/ibm"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := ibm.NewComputeVmInstance(ctx, "vm1", &ibm.ComputeVmInstanceArgs{
SshKeyIds: pulumi.Float64Array{
data.Ibm_compute_ssh_key.Public_key.Id,
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Ibm = Pulumi.Ibm;
return await Deployment.RunAsync(() =>
{
var vm1 = new Ibm.ComputeVmInstance("vm1", new()
{
SshKeyIds = new[]
{
data.Ibm_compute_ssh_key.Public_key.Id,
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.ibm.ComputeVmInstance;
import com.pulumi.ibm.ComputeVmInstanceArgs;
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) {
var vm1 = new ComputeVmInstance("vm1", ComputeVmInstanceArgs.builder()
.sshKeyIds(data.ibm_compute_ssh_key().public_key().id())
.build());
}
}
resources:
vm1:
type: ibm:ComputeVmInstance
properties:
# TF-UPGRADE-TODO: In Terraform v0.10 and earlier, it was sometimes necessary to
# # force an interpolation expression to be interpreted as a list by wrapping it
# # in an extra set of list brackets. That form was supported for compatibility in
# # v0.11, but is no longer supported in Terraform v0.12.
# #
# # If the expression in the following list itself returns a list, remove the
# # brackets to avoid interpretation as a list of lists. If the expression
# # returns a single list item then leave it as-is and remove this TODO comment.
sshKeyIds:
- ${data.ibm_compute_ssh_key.public_key.id}
Using getComputeSshKey
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 getComputeSshKey(args: GetComputeSshKeyArgs, opts?: InvokeOptions): Promise<GetComputeSshKeyResult>
function getComputeSshKeyOutput(args: GetComputeSshKeyOutputArgs, opts?: InvokeOptions): Output<GetComputeSshKeyResult>
def get_compute_ssh_key(id: Optional[str] = None,
label: Optional[str] = None,
most_recent: Optional[bool] = None,
opts: Optional[InvokeOptions] = None) -> GetComputeSshKeyResult
def get_compute_ssh_key_output(id: Optional[pulumi.Input[str]] = None,
label: Optional[pulumi.Input[str]] = None,
most_recent: Optional[pulumi.Input[bool]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetComputeSshKeyResult]
func LookupComputeSshKey(ctx *Context, args *LookupComputeSshKeyArgs, opts ...InvokeOption) (*LookupComputeSshKeyResult, error)
func LookupComputeSshKeyOutput(ctx *Context, args *LookupComputeSshKeyOutputArgs, opts ...InvokeOption) LookupComputeSshKeyResultOutput
> Note: This function is named LookupComputeSshKey
in the Go SDK.
public static class GetComputeSshKey
{
public static Task<GetComputeSshKeyResult> InvokeAsync(GetComputeSshKeyArgs args, InvokeOptions? opts = null)
public static Output<GetComputeSshKeyResult> Invoke(GetComputeSshKeyInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetComputeSshKeyResult> getComputeSshKey(GetComputeSshKeyArgs args, InvokeOptions options)
public static Output<GetComputeSshKeyResult> getComputeSshKey(GetComputeSshKeyArgs args, InvokeOptions options)
fn::invoke:
function: ibm:index/getComputeSshKey:getComputeSshKey
arguments:
# arguments dictionary
The following arguments are supported:
- Label string
- The label of the SSH key.
- Id string
- (String) The unique identifier of the SSH key.
- Most
Recent bool
- Label string
- The label of the SSH key.
- Id string
- (String) The unique identifier of the SSH key.
- Most
Recent bool
- label String
- The label of the SSH key.
- id String
- (String) The unique identifier of the SSH key.
- most
Recent Boolean
- label string
- The label of the SSH key.
- id string
- (String) The unique identifier of the SSH key.
- most
Recent boolean
- label str
- The label of the SSH key.
- id str
- (String) The unique identifier of the SSH key.
- most_
recent bool
- label String
- The label of the SSH key.
- id String
- (String) The unique identifier of the SSH key.
- most
Recent Boolean
getComputeSshKey Result
The following output properties are available:
- Fingerprint string
- (String) The sequence of bytes to authenticate or look up a longer SSH key.
- Id string
- (String) The unique identifier of the SSH key.
- Label string
- Notes string
- (String) The notes that are stored with the SSH key.
- Public
Key string - (String) The public key contents.
- Most
Recent bool
- Fingerprint string
- (String) The sequence of bytes to authenticate or look up a longer SSH key.
- Id string
- (String) The unique identifier of the SSH key.
- Label string
- Notes string
- (String) The notes that are stored with the SSH key.
- Public
Key string - (String) The public key contents.
- Most
Recent bool
- fingerprint String
- (String) The sequence of bytes to authenticate or look up a longer SSH key.
- id String
- (String) The unique identifier of the SSH key.
- label String
- notes String
- (String) The notes that are stored with the SSH key.
- public
Key String - (String) The public key contents.
- most
Recent Boolean
- fingerprint string
- (String) The sequence of bytes to authenticate or look up a longer SSH key.
- id string
- (String) The unique identifier of the SSH key.
- label string
- notes string
- (String) The notes that are stored with the SSH key.
- public
Key string - (String) The public key contents.
- most
Recent boolean
- fingerprint str
- (String) The sequence of bytes to authenticate or look up a longer SSH key.
- id str
- (String) The unique identifier of the SSH key.
- label str
- notes str
- (String) The notes that are stored with the SSH key.
- public_
key str - (String) The public key contents.
- most_
recent bool
- fingerprint String
- (String) The sequence of bytes to authenticate or look up a longer SSH key.
- id String
- (String) The unique identifier of the SSH key.
- label String
- notes String
- (String) The notes that are stored with the SSH key.
- public
Key String - (String) The public key contents.
- most
Recent Boolean
Package Details
- Repository
- ibm ibm-cloud/terraform-provider-ibm
- License
- Notes
- This Pulumi package is based on the
ibm
Terraform Provider.