✨ Features
Support trusted_key_groups per ordered_cache_behavior @finchr (#169)
## what- Add
trusted_key_groups(list(string), default[]) as a per-entry field on theordered_cacheobject type invariables.tf. - Wire it into the
ordered_cache_behaviordynamic block inmain.tf, independent of the existing module-leveltrusted_signers. - Add
examples/signed-media: creates a realaws_cloudfront_public_key+aws_cloudfront_key_group, then a distribution with twoordered_cacheentries —/media/*setstrusted_key_groups,/api/*doesn't — to demonstrate the requirement stays scoped to the one behavior that sets it.
Fully additive. trusted_key_groups defaults to [], so every existing ordered_cache entry (and anything relying on the current global trusted_signers) behaves exactly as before.
why
ordered_cache_behaviorcurrently hardcodestrusted_signers = var.trusted_signers— one module-level list, applied identically to every entry invar.ordered_cache. There's no way to require signing on just one path pattern without forcing it onto every other ordered cache behavior on the same distribution.trusted_key_groups, the modern, AWS-recommended replacement fortrusted_signers(which depends on legacy, account-level CloudFront key pairs), wasn't exposed onordered_cacheat all.- Without this, protecting one path (e.g. signed-cookie media) behind an existing distribution that also serves an unsigned path (e.g.
/api/*) isn't possible — the only workaround is a second CloudFront distribution just for the signed path, with its own hostname, DNS record, certificate alias, and bucket-policy wiring. - Verified with a real
terraform planagainstexamples/signed-media: the/media/*ordered_cache_behaviorgetstrusted_key_groupsset,/api/*gets[], anddefault_cache_behavioris untouched either way.
references
- Closes #168