Skip to content

Commit 1e91315

Browse files
authored
[usage-plan] add throttle settings (#28)
* [usage-plan] add throttle settings
1 parent 531e714 commit 1e91315

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

modules/usage_plan/main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ resource "aws_api_gateway_usage_plan" "usage_plan" {
2121
}
2222
}
2323

24+
dynamic "throttle_settings" {
25+
for_each = var.enable_throttling == true ? [1] : []
26+
content {
27+
burst_limit = var.burst_limit
28+
rate_limit = var.rate_limit
29+
}
30+
}
31+
2432
tags = {
2533
Name = var.name
2634
}

modules/usage_plan/variables.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,24 @@ variable "period" {
4848
default = "MONTH"
4949
}
5050

51+
variable "enable_throttling" {
52+
description = "whether to enable throttling"
53+
type = bool
54+
default = false
55+
}
56+
57+
variable "burst_limit" {
58+
description = "The maximum number of requests that API Gateway allows to be bursted across the entire API at the same moment."
59+
type = number
60+
default = 5000
61+
}
62+
63+
variable "rate_limit" {
64+
description = "The rate limit, as a number of requests per second, to apply to this usage plan."
65+
type = number
66+
default = 100
67+
}
68+
5169
variable "api_keys" {
5270
description = "List of api keys created and assigned to the usage plan"
5371
type = map(

0 commit comments

Comments
 (0)