Skip to content

Allow capturing the public key from ephemeral.tls_private_key into a non-ephemeral/non-WO resource #648

Description

@ari-becker

Terraform CLI and Provider Versions

1.11 / 4.1.0

Use Cases or Problem Statement

ephemeral.tls_private_key will produce both a private key and a public key. While it is indeed important for the private key to not be stored in Terraform state, and the ephemerality helps ensure that it is copied into a secret store for further processing, there should be a way to capture the paired public key from ephemeral.tls_private_key and store the public key in a standard resource (e.g. Kubernetes ConfigMap, object bucket, module output, etc.)

Proposal

Something like the following:

ephemeral "tls_private_key" "foo" {
   algorithm = "RSA"
   rsa_bits = 4096
 }

 resource "google_secret_manager_secret_version" "foo" {
   secret_data_wo = ephemeral.tls_private_key.foo.private_key_pem
   secret_data_wo_version = 1
 }

resource "terraform_data" "foo" {
  input_wo = ephemeral.tls_private_key.foo.public_key_pem
  input_wo_version = 1
}

output "public_key" {
  value = terraform_data.foo.output
}

How much impact is this issue causing?

High

Additional Information

hashicorp/terraform#36941

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions