Skip to content

Add dynamic header injection based on request path#31

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-dynamic-terraform-block
Draft

Add dynamic header injection based on request path#31
Copilot wants to merge 2 commits intomainfrom
copilot/add-dynamic-terraform-block

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 31, 2026

Adds support for conditionally setting request headers based on URL path matching via a new add_header_based_on_path variable.

Changes

  • modules/service-vcl/variables.tf — New add_header_based_on_path variable: list(object({ path, header_name, header_value }))
  • modules/service-vcl/vcl-service.tf — Two new dynamic blocks:
    • dynamic "condition" — generates a REQUEST condition per entry matching req.url.path
    • dynamic "header" — sets the named header to the specified value, gated by the corresponding path condition
  • prod-delivery/variables.tf — Mirrors the same variable declaration
  • prod-delivery/main.tf — Passes add_header_based_on_path through to the module

Example

add_header_based_on_path = [
  { path = "/anything/foo",     header_name = "foo",     header_value = "a" },
  { path = "/anything/bar",     header_name = "bar",     header_value = "b" },
  { path = "/anything/charlie", header_name = "charlie", header_value = "c" },
]

Condition and header action names are derived from the path (e.g., /anything/foopath-condition-anything-foo, header-foo-anything-foo) to ensure uniqueness across entries.

…ariable

Agent-Logs-Url: https://github.com/fastly/security-use-cases/sessions/89ca44d8-3889-4092-a301-46e601599557

Co-authored-by: BrooksCunningham <22921241+BrooksCunningham@users.noreply.github.com>
Copilot AI changed the title [WIP] Add dynamic terraform block for header addition based on path Add dynamic header injection based on request path Mar 31, 2026
Copilot AI requested a review from BrooksCunningham March 31, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants