Skip to content

Commit

Permalink
Add rate limiter to www.gov.uk/bank-holidays.json
Browse files Browse the repository at this point in the history
  • Loading branch information
samsimpson1 committed Feb 3, 2025
1 parent 88141ba commit 5c9c3c1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dictionaries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ example_percentages:
bankholidaystest_percentages:
A: 99
B: 1
# Dictionary for /bank-holidays.json rate limiter
bankholidaysjson_ratelimiter:
/bank-holidays.json: 'Bank Holidays JSON'
21 changes: 21 additions & 0 deletions www/service.tf
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,27 @@ resource "fastly_service_vcl" "service" {
}
}

rate_limiter {
name = "rate_limiter_bank_holidays_json"

rps_limit = 5
window_size = 10
penalty_box_duration = 10

uri_dictionary_name = "bankholidaysjson_ratelimiter"

client_key = "req.http.Fastly-Client-IP"
http_methods = "GET,PUT,TRACE,POST,HEAD,DELETE,PATCH,OPTIONS"

action = "response"

response {
content = "Too many requests"
content_type = "plain/text"
status = 429
}
}

dynamic "logging_splunk" {
for_each = {
for splunk in try(local.secrets["splunk"], []) : splunk.name => splunk
Expand Down

0 comments on commit 5c9c3c1

Please sign in to comment.