Skip to content

Commit

Permalink
Merge pull request #125 from GovTechSG/lamda-api-gateway/parameterize…
Browse files Browse the repository at this point in the history
…-quota-throttle-limit

Added parameters for api gateway throttling
  • Loading branch information
ryanoolala authored Aug 2, 2018
2 parents db78b56 + b41a9cf commit 84e19b2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
4 changes: 4 additions & 0 deletions modules/lambda-api-gateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,15 @@ variable "image_name" {
| iam_role_name | IAM Role Name that has policies attached to execute lambda functions | string | - | yes |
| lambda_handler_name | Name of the handler in lambda function e.g. main.handler | string | - | yes |
| lambda_timeout | Timeout afterwhich to kill the function | string | `10` | no |
| quota_limit | Maximum number of api calls for the usage plan | string | `100` | no |
| quota_period | Period in which the limit is accumulated, eg DAY, WEEK, MONTH | string | `DAY` | no |
| runtime | Lambda Runtime your function uses e.g. nodejs8.10 | string | - | yes |
| s3_bucket | S3 Bucket Name | string | - | yes |
| s3_key | Directory of the zip file inside the S3 bucket e.g. SomePath/${var.app_version}/function.zip | string | - | yes |
| security_group | List of security group to add to your function | list | - | yes |
| subnet_id | List of subnets to run your function in | list | - | yes |
| throttle_burst_limit | Burst token bucket | string | `5` | no |
| throttle_rate_limit | Rate at which burst tokens are added to bucket | string | `10` | no |
| vpc_id | VPC that your function will run in. Used when your function requires an internal IP for accessing internal services | string | - | yes |

## Outputs
Expand Down
9 changes: 4 additions & 5 deletions modules/lambda-api-gateway/api-gateway.tf
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,12 @@ resource "aws_api_gateway_usage_plan" "deploy-api-gw-usage-plan" {
}

quota_settings {
limit = 20
offset = 2
period = "WEEK"
limit = "${var.quota_limit}"
period = "${var.quota_period}"
}

throttle_settings {
burst_limit = 5
rate_limit = 10
burst_limit = "${var.throttle_burst_limit}"
rate_limit = "${var.throttle_rate_limit}"
}
}
20 changes: 20 additions & 0 deletions modules/lambda-api-gateway/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,23 @@ variable "lambda_timeout" {
description = "Timeout afterwhich to kill the function"
default = "10"
}

variable "quota_limit" {
description = "Maximum number of api calls for the usage plan"
default = 100
}

variable "quota_period" {
description = "Period in which the limit is accumulated, eg DAY, WEEK, MONTH"
default = "DAY"
}

variable "throttle_burst_limit" {
description = "Burst token bucket"
default = 5
}

variable "throttle_rate_limit" {
description = "Rate at which burst tokens are added to bucket"
default = 10
}

0 comments on commit 84e19b2

Please sign in to comment.