DianaIonita / serverless-api-gateway-throttling

A plugin for the Serverless framework which configures throttling for API Gateway endpoints.
ISC License
69 stars 7 forks source link

Error: settings.httpApiEndpointSettings is not iterable #30

Closed Lpfigueiredo closed 1 year ago

Lpfigueiredo commented 1 year ago

Hi! I'm trying to use the plugin but i'm getting the following error when running serverless deploy:

TypeError: settings.httpApiEndpointSettings is not iterable at updateHttpApi (C:\cursos\serverless_test\aws-node-http-api-project\node_modules\serverless-api-gateway-throttling\src\updateHttpApiStageThrottling.js:9:52) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async ApiGatewayThrottlingPlugin.updateStage (C:\cursos\serverless_test\aws-node-http-api-project\node_modules\serverless-api-gateway-throttling\src\apiGatewayThrottlingPlugin.js:67:7)

My serverless.yml is:

service: aws-node-http-api-project
frameworkVersion: '3'

provider:
  name: aws
  runtime: nodejs14.x

plugins:
  - serverless-api-gateway-throttling

functions:
  hello:
    handler: handler.hello
    events:
      - httpApi:
          path: /
          method: get
          throttling:
            maxRequestsPerSecond: 3000
            maxConcurrentRequests: 1000

I'm using the Serverless HTTP API example. When I disable the plugin, the deployment occurs normally. I tried to re-deploy but the error persists.

Can you help me, please? Thanks

DianaIonita commented 1 year ago

Hi @Lpfigueiredo,

Please check that you've configured the plugin like in the example in the Readme. Your serverless.yml doesn't show custom.apiGatewayThrottling settings:

plugins:
  - serverless-api-gateway-throttling

custom:
  # Configures throttling settings for the API Gateway stage
  # They apply to all http endpoints, unless specifically overridden
  apiGatewayThrottling:
    maxRequestsPerSecond: 1000
    maxConcurrentRequests: 500

Let me know if you're still having problems after that.

Lpfigueiredo commented 1 year ago

It worked! Thank you very much

asad-aiden commented 1 year ago

Can we configure throttling values as env variable For example apiGatewayThrottling: maxRequestsPerSecond: ${en:var1}
maxConcurrentRequests: ${env:var2}

DianaIonita commented 1 year ago

Hey @asad-aiden, Sure, you can configure your parameters to come from wherever the serverless framework supports. Here's a helpful guide: https://www.serverless.com/framework/docs/providers/aws/guide/variables