Ready to level-up your engineering skills? Join a Pulumi Workshop. Register Now

getPublicKey

Use this data source to get the public key from a PEM-encoded private key for use in other resources.

Example Usage

using System.IO;
using Pulumi;
using Tls = Pulumi.Tls;

class MyStack : Stack
{
    public MyStack()
    {
        var example = Output.Create(Tls.GetPublicKey.InvokeAsync(new Tls.GetPublicKeyArgs
        {
            PrivateKeyPem = File.ReadAllText("~/.ssh/id_rsa"),
        }));
    }

}

Coming soon!

import pulumi
import pulumi_tls as tls

example = tls.get_public_key(private_key_pem=(lambda path: open(path).read())("~/.ssh/id_rsa"))
import * as pulumi from "@pulumi/pulumi";
import * as fs from "fs";
import * as tls from "@pulumi/tls";

const example = pulumi.output(tls.getPublicKey({
    privateKeyPem: fs.readFileSync("~/.ssh/id_rsa", "utf-8"),
}, { async: true }));

Using getPublicKey

function getPublicKey(args: GetPublicKeyArgs, opts?: InvokeOptions): Promise<GetPublicKeyResult>
def get_public_key(private_key_pem: Optional[str] = None, opts: Optional[InvokeOptions] = None) -> GetPublicKeyResult
func GetPublicKey(ctx *Context, args *GetPublicKeyArgs, opts ...InvokeOption) (*GetPublicKeyResult, error)

Note: This function is named GetPublicKey in the Go SDK.

public static class GetPublicKey {
    public static Task<GetPublicKeyResult> InvokeAsync(GetPublicKeyArgs args, InvokeOptions? opts = null)
}

The following arguments are supported:

PrivateKeyPem string

The private key to use. Currently-supported key types are “RSA” or “ECDSA”.

PrivateKeyPem string

The private key to use. Currently-supported key types are “RSA” or “ECDSA”.

privateKeyPem string

The private key to use. Currently-supported key types are “RSA” or “ECDSA”.

private_key_pem str

The private key to use. Currently-supported key types are “RSA” or “ECDSA”.

getPublicKey Result

The following output properties are available:

Algorithm string
Id string

The provider-assigned unique ID for this managed resource.

PrivateKeyPem string

The private key data in PEM format.

PublicKeyFingerprintMd5 string

The md5 hash of the public key data in OpenSSH MD5 hash format, e.g. aa:bb:cc:.... Only available if the selected private key format is compatible, as per the rules for public_key_openssh.

PublicKeyOpenssh string

The public key data in OpenSSH authorized_keys format, if the selected private key format is compatible. All RSA keys are supported, and ECDSA keys with curves “P256”, “P384” and “P521” are supported. This attribute is empty if an incompatible ECDSA curve is selected.

PublicKeyPem string

The public key data in PEM format.

Algorithm string
Id string

The provider-assigned unique ID for this managed resource.

PrivateKeyPem string

The private key data in PEM format.

PublicKeyFingerprintMd5 string

The md5 hash of the public key data in OpenSSH MD5 hash format, e.g. aa:bb:cc:.... Only available if the selected private key format is compatible, as per the rules for public_key_openssh.

PublicKeyOpenssh string

The public key data in OpenSSH authorized_keys format, if the selected private key format is compatible. All RSA keys are supported, and ECDSA keys with curves “P256”, “P384” and “P521” are supported. This attribute is empty if an incompatible ECDSA curve is selected.

PublicKeyPem string

The public key data in PEM format.

algorithm string
id string

The provider-assigned unique ID for this managed resource.

privateKeyPem string

The private key data in PEM format.

publicKeyFingerprintMd5 string

The md5 hash of the public key data in OpenSSH MD5 hash format, e.g. aa:bb:cc:.... Only available if the selected private key format is compatible, as per the rules for public_key_openssh.

publicKeyOpenssh string

The public key data in OpenSSH authorized_keys format, if the selected private key format is compatible. All RSA keys are supported, and ECDSA keys with curves “P256”, “P384” and “P521” are supported. This attribute is empty if an incompatible ECDSA curve is selected.

publicKeyPem string

The public key data in PEM format.

algorithm str
id str

The provider-assigned unique ID for this managed resource.

private_key_pem str

The private key data in PEM format.

public_key_fingerprint_md5 str

The md5 hash of the public key data in OpenSSH MD5 hash format, e.g. aa:bb:cc:.... Only available if the selected private key format is compatible, as per the rules for public_key_openssh.

public_key_openssh str

The public key data in OpenSSH authorized_keys format, if the selected private key format is compatible. All RSA keys are supported, and ECDSA keys with curves “P256”, “P384” and “P521” are supported. This attribute is empty if an incompatible ECDSA curve is selected.

public_key_pem str

The public key data in PEM format.

Package Details

Repository
https://github.com/pulumi/pulumi-tls
License
Apache-2.0
Notes
This Pulumi package is based on the tls Terraform Provider.