-
Notifications
You must be signed in to change notification settings - Fork 114
feat: support ephemeral private keys for self signed certificates #689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: support ephemeral private keys for self signed certificates #689
Conversation
…em write only attributes supports hashicorp#645 Write-only attribute support for TLS managed resources
Hey @deniseyu and @austinvalle, tagging you for visibility. Do you see a path for getting this merged? The new write-only argument introduced here is useful for securely creating self-signed certificates—without it, the private key would be exposed in the state. The beauty of this write-only argument is that it enables a pattern similar to the ephemeral ephemeral tls_private_key "demo" {
algorithm = "RSA"
rsa_bits = 2048
}
resource "tls_self_signed_cert" "demo" {
private_key_pem_wo = ephemeral.tls_private_key.demo.private_key_pem
private_key_pem_wo_version = 1
subject {
common_name = "example.com"
organization = "ACME Examples, Inc"
}
validity_period_hours = 24 * 30
allowed_uses = [
"key_encipherment",
"digital_signature",
"server_auth",
]
}
resource "vault_kv_secret_v2" "demo_private_key" {
mount = vault_mount.kvv2.path
name = "demo_private_key"
cas = 1
delete_all_versions = true
data_json_wo = jsonencode(
{
private_key = ephemeral.tls_private_key.demo.private_key_pem,
}
)
data_json_wo_version = tls_self_signed_cert.demo.private_key_pem_wo_version
} Thanks! |
I actually need the write only properties to create a google service account key by uploading the public key and storing the service account key with the private key directly in the secret manager.
Of course, for refreshing the certificate, the private key should be stored in a google secret manager secret and retrieved via an ephemeral google_secret_manager_secret_version. |
Once this one is approved, I have the PRs for tls_cert_request and tls_locally_signed_cert ready which are pretty similar. https://github.com/mvanholsteijn/terraform-provider-tls/tree/feat/tls-cert-request/support-write-only-private-key |
Adds the properties private_key_pem_wo and private_key_pem_wo_version to support the use of ephemeral private keys for self signed certificates, keeping the private key out of the state file.
Related Issue
#645
Description
Added support for a write-only private_key_pem as described in https://developer.hashicorp.com/terraform/plugin/framework/resources/write-only-arguments
Rollback Plan
Changes to Security Controls
nope.