Skip to content

Let cloudfront_intercode distributions share their cache and origin request policies - #12488

Merged
nbudin merged 1 commit into
mainfrom
shared-cloudfront-policies
Nov 24, 2026
Merged

nbudin merged 1 commit into
mainfrom
shared-cloudfront-policies

Conversation

@nbudin

@nbudin nbudin commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Why

An AWS account can hold at most 20 CloudFront cache policies, and each cloudfront_intercode distribution created 5 of its own (plus 2 origin request policies). The NEIL account is at 20 of 20 with three distributions (i, p and the framework-shell test one), so the next convention moved behind CloudFront would fail to apply. Within one account the policies are identical across distributions, so this is waste, not a need.

What

  • New cloudfront_intercode_policies module: the 5 cache policies and 2 origin request policies, moved out of cloudfront_intercode unchanged, with cache_policy_ids and origin_request_policy_ids outputs.
  • cloudfront_intercode takes an optional shared_policies input. Without it, it creates its own set through the new module, so existing users don't have to change anything; moved blocks carry their state across.
  • static_shell_max_ttl on the new module (default: the same as static_shell_ttl, so no change). CloudFront caps a stale-while-revalidate window at the policy's maximum TTL, so a longer window needs this raised. Not used yet.
  • README section on sharing, and the new module in the CI validate matrix.

Checked

  • tofu validate on both modules; Prettier on the README and workflow.
  • A tofu plan against the production state with neil-terraform pointed at this branch:
    • The refactor alone: 0 to add, 0 to change, 0 to destroy (21 policy resources recognized as moved).
    • With one distribution's policies adopted as the shared set (neil-terraform follow-up): 0 to add, 9 to change, 14 to destroy. The shared policies are renamed in place with their IDs kept, the other two distributions are updated in place (only the policy IDs change), and their 14 duplicate policies are destroyed. Nothing is replaced.
  • A scratch CloudFront distribution showed the stale-while-revalidate window is the TTL plus the lesser of the directive and the maximum TTL.

Not checked

  • The CI run on this PR.
  • Nothing has been applied; the neil-terraform change comes after this merges.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UKBUsvfbUjKBu9d6FJoEuJ

…equest policies

An AWS account holds at most 20 cache policies, and every cloudfront_intercode
distribution created 5 of its own (plus 2 origin request policies). They don't
depend on the distribution, so the account was at 20 of 20 with three
distributions, and the next convention moved behind CloudFront would have
failed to apply.

Move the policies into a new cloudfront_intercode_policies module. The
distribution module takes an optional shared_policies input; without it, it
creates its own set through the same module, so existing users are unaffected
(moved blocks keep their state). A shared set can also give the static shell a
longer maximum TTL than its default TTL (static_shell_max_ttl), which
CloudFront needs for a stale-while-revalidate window longer than the TTL.

Checked with a plan against the production state: the refactor alone changes
nothing, and adopting one distribution's policies as the shared set renames
them in place, updates the other distributions in place and destroys their
duplicates, with no replacements.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UKBUsvfbUjKBu9d6FJoEuJ
@nbudin nbudin added tech debt patch Bumps the patch version number on release chore Maintenance and refactoring with no user-facing change and removed tech debt labels Nov 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage Report: Only Changed Files listed

Package Base Coverage New Coverage Difference
app/javascript/setupI18Next.ts 🟢 89.66% 🟢 82.76% 🔴 -6.9%
Overall Coverage 🟢 69.9% 🟢 69.9% ⚪ 0%

Minimum allowed coverage is 0%, this run produced 69.9%

@nbudin
nbudin merged commit 3d91111 into main Nov 24, 2026
26 checks passed
@nbudin
nbudin deleted the shared-cloudfront-policies branch November 24, 2026 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Maintenance and refactoring with no user-facing change patch Bumps the patch version number on release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant