» Data Source: tls_public_key

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

» Example Usage

data "tls_public_key" "example" {
  private_key_pem = "${file("~/.ssh/id_rsa")}"

» Argument Reference

The following arguments are supported:

  • private_key_pem - (Required) The private key to use. Currently-supported key types are "RSA" or "ECDSA".

» Attributes Reference

The following attributes are exported:

  • private_key_pem - The private key data in PEM format.
  • public_key_pem - The public key data in PEM format.
  • public_key_openssh - 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 "P251" are supported. This attribute is empty if an incompatible ECDSA curve is selected.