Terraform TLS Policy Inventory for Post-Quantum Migration
The NSA asked for an immediate post-quantum transition. Use Terraform state to list every TLS policy you run, then control the policy from one variable.
DevOps
Q-Day is when quantum computers break RSA and elliptic curves. Use Terraform state and jq to list every KMS key, ACM certificate and TLS key before Y2Q.
Q-Day is the day a quantum computer can break RSA and elliptic-curve cryptography. Y2Q ("years to quantum") is the countdown to it. Nobody knows the date. The NIST plan in IR 8547 gives the planning dates: these algorithms are deprecated after 2030 and disallowed after 2035.
The TLS policy inventory showed where your endpoints negotiate keys. This article finds the keys themselves: the asymmetric keys and certificates that your Terraform state already knows.
| Resource | Example | On Q-Day |
|---|---|---|
| Symmetric KMS key | SYMMETRIC_DEFAULT (AES-256) | Stays secure |
| Asymmetric KMS key | RSA_2048, ECC_NIST_P256 | Broken |
| ACM certificate | RSA_2048, EC_prime256v1 | Signature can be forged |
tls_private_key | RSA, ECDSA, ED25519 | Broken |
Most KMS keys are symmetric. This is good news: the list of keys that need work is shorter than the list of all keys.
terraform show -json | jq -r '
.. | objects
| select(.type? == "aws_kms_key")
| select(.values.customer_master_key_spec != "SYMMETRIC_DEFAULT")
| [.address, .values.customer_master_key_spec, .values.key_usage] | @tsv'Each line is a key that signs, verifies or wraps data with RSA or elliptic curves. Write down what uses it: code signing, JWT signing, envelope encryption for another system.
terraform show -json | jq -r '
.. | objects
| select(.type? == "aws_acm_certificate")
| [.address, .values.domain_name, .values.key_algorithm, .values.not_after] | @tsv'Public certificates rotate in months, so the algorithm changes with a renewal. Imported certificates and private CA certificates with long lifetimes are the ones to mark.
terraform show -json | jq -r '
.. | objects
| select(.type? == "tls_private_key")
| [.address, .values.algorithm, (.values.rsa_bits // .values.ecdsa_curve // "-")] | @tsv'A tls_private_key resource also keeps the private key in state. That is a separate problem to solve, with or without quantum computers.
#!/usr/bin/env bash
# Usage: ./q-day-inventory.sh dir1 dir2 ...
set -euo pipefail
for dir in "$@"; do
terraform -chdir="$dir" show -json | jq -r --arg ws "$dir" '
.. | objects
| select(.type? == "aws_kms_key" or .type? == "aws_acm_certificate" or .type? == "tls_private_key")
| [$ws, .type, .address,
(.values.customer_master_key_spec // .values.key_algorithm // .values.algorithm)]
| @tsv'
done | grep -v "SYMMETRIC_DEFAULT" | sortThe output is a tab-separated list: workspace, resource type, address, algorithm.
When an algorithm name is typed in each resource, a migration is a search in every repository. Put it in one place:
variable "signing_key_spec" {
description = "Key spec for asymmetric signing keys"
type = string
default = "ECC_NIST_P384"
}
resource "aws_kms_key" "signing" {
description = "Artifact signing key"
key_usage = "SIGN_VERIFY"
customer_master_key_spec = var.signing_key_spec
}A change of key spec replaces the key. Plan it like a key rotation: create the new key, move the consumers, then remove the old key. When your provider version supports a post-quantum key spec, you change one default and follow the same process.
Use Mosca's inequality. X is the number of years the protected data must stay secret, Y is the number of years your migration takes, Z is the number of years to Q-Day. If X + Y is larger than Z, that key is late.
You do not need the date of Q-Day to start. You need the list. Three jq commands on your state give it to you today.
For hybrid TLS policies and KMS details, see Terraform for Post-Quantum Cryptography: Migrate TLS and KMS.
The NSA asked for an immediate post-quantum transition. Use Terraform state to list every TLS policy you run, then control the policy from one variable.
DevOpsPrepare for post-quantum cryptography with Terraform. Configure hybrid TLS policies, KMS key types, ACM certificates
Provision digital provenance and C2PA content signing infrastructure with Terraform: certificate authorities, signing services, ledgers, and verification APIs.
DevOpsSecure AI workloads with Terraform. Deploy Bedrock guardrails, model access IAM policies, prompt injection detection