diff --git a/modules/lambda-api-gateway/README.md b/modules/lambda-api-gateway/README.md index c967d517..4e6b6d1f 100644 --- a/modules/lambda-api-gateway/README.md +++ b/modules/lambda-api-gateway/README.md @@ -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 diff --git a/modules/lambda-api-gateway/api-gateway.tf b/modules/lambda-api-gateway/api-gateway.tf index 76bdfb00..582f1d08 100644 --- a/modules/lambda-api-gateway/api-gateway.tf +++ b/modules/lambda-api-gateway/api-gateway.tf @@ -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}" } } diff --git a/modules/lambda-api-gateway/variables.tf b/modules/lambda-api-gateway/variables.tf index 849e51a8..38d25402 100644 --- a/modules/lambda-api-gateway/variables.tf +++ b/modules/lambda-api-gateway/variables.tf @@ -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 +}