fix(kms): use regime-aware local for kms_protection_level and propagate to downstream stages - #233
AloysJehwin wants to merge 2 commits into
Conversation
…te to downstream stages kms.tf used var.kms_protection_level directly, ignoring the coalesce-based local that computes a regime-aware default (SOFTWARE for FedRAMP Moderate, HSM otherwise). An operator following the deployment guide saw four interactive prompts for an undocumented variable; pressing Enter silently downgraded KMS protection from HSM to empty string on FedRAMP High deployments. - kms.tf: use local.kms_protection_level instead of var.kms_protection_level - outputs.tf: add kms_protection_level to tfvars so stages 1/2/3 inherit it - stages 1/2/3 variables.tf: add default = null and tfdoc:variable:source - terraform.tfvars.sample: document the variable with a comment Fixes google#231 Signed-off-by: Aloys Jehwin <aloysjehwin@gmail.com>
| version_template = { | ||
| algorithm = "GOOGLE_SYMMETRIC_ENCRYPTION" | ||
| protection_level = var.kms_protection_level | ||
| protection_level = local.kms_protection_level |
There was a problem hiding this comment.
I don't think we even use local.protection_level anywhere, would suggest removing this altogether if that is the case
There was a problem hiding this comment.
For consolidate, can you move the local declaration of local.kms_protection_level from main.tf into kms.tf? I think this will make it easier to track
Per review, the local is declared beside the keys that consume it rather than in main.tf, so the regime-aware default and the version_template that uses it are read together. No behavior change: the coalesce expression is unchanged and locals are stage-scoped, so outputs.tf still resolves it. Claude-Session: https://claude.ai/code/session_01CFRv5kvesfnKYgHmNw9Vpf
|
Thanks for the review — pushed acf8520. Moved the local into On removing locals {
version_template = {
algorithm = "GOOGLE_SYMMETRIC_ENCRYPTION"
protection_level = local.kms_protection_level
}
}
The map it belongs to is consumed by both keys in this stage:
Happy to remove something if I've misread which line you meant — could you point me at it? Otherwise I think this one is a no-op and the branch is ready for another look. |
Summary
Fixes #231.
kms.tfreferencedvar.kms_protection_leveldirectly instead of the already-computedlocal.kms_protection_level. That local usescoalesceto apply a regime-aware default (SOFTWARE for FEDRAMP_MODERATE, HSM for all other regimes). The bypass meant:version_template.protection_levelwould be an empty string unless the operator explicitly set the variable.Changes
0-bootstrap/kms.tf(line 18):var.kms_protection_level→local.kms_protection_level0-bootstrap/outputs.tf(line 111, 168): addkms_protection_level = local.kms_protection_leveltolocal.tfvarsso stages 1/2/3 receive it via.auto.tfvars.json; also fix standalone output to use the local1-resman/variables.tf,2-networking-a-fedramp/variables.tf,3-security/variables.tf: adddefault = nulland# tfdoc:variable:source 0-bootstraptokms_protection_leveldeclarations0-bootstrap/terraform.tfvars.sample: document the variable with an explanatory commentTest plan
terraform validatepasses in0-bootstrap,1-resman,2-networking-a-fedramp,3-securitylocal.kms_protection_levelresolves toSOFTWARElocal.kms_protection_levelresolves toHSMkms_protection_levelfrom.auto.tfvars.jsonwithout promptingSigned-off-by: Aloys Jehwin aloysjehwin@gmail.com