rrahul963/serverless-add-api-key

TypeError: apiKeyDefinition[name].forEach is not a function

satyami2tech opened this issue · 0 comments

Here is my code for setting up API keys.

service: thirdparty-api
frameworkVersion: "^3.19.0"

plugins:
  - serverless-add-api-key

provider:
  name: aws
  runtime: nodejs14.x
  tags:
    version: v0.0.1
  stage: ${opt:stage, 'dev'}
  deploymentBucket: serverless-deployment
  region: 'us-west-2'
  logs:
    restApi: true
  vpc:
    securityGroupIds:
      - SG
    subnetIds:
      - SUB_NET1 #Private Subnet
      - SUB_NET2 #Private Subnet
  apiGateway:
    apiKeys:
      - name: privateSertifiKey
        value: 'valueofkeyhere'
        usagePlan:
          - name: privateSertifi
            quota:
              limit: 1000000
              period: MONTH
            throttle:
              rateLimit: 1000
              burstLimit: 500

and in function yaml, I've added private as true for respective method.

At build time, it is throwing this error.

Error:
TypeError: apiKeyDefinition[name].forEach is not a function
at /codebuild/output/src276954272/src/thirdparty-api/node_modules/serverless/lib/plugins/aws/package/compile/events/api-gateway/lib/api-keys.js:49:34
at Array.forEach (<anonymous>)
at AwsCompileApigEvents.compileApiKeys (/codebuild/output/src276954272/src/thirdparty-api/node_modules/serverless/lib/plugins/aws/package/compile/events/api-gateway/lib/api-keys.js:39:15)
at AwsCompileApigEvents.tryCatcher (/codebuild/output/src276954272/src/thirdparty-api/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/codebuild/output/src276954272/src/thirdparty-api/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/codebuild/output/src276954272/src/thirdparty-api/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/codebuild/output/src276954272/src/thirdparty-api/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/codebuild/output/src276954272/src/thirdparty-api/node_modules/bluebird/js/release/promise.js:729:18)
at _drainQueueStep (/codebuild/output/src276954272/src/thirdparty-api/node_modules/bluebird/js/release/async.js:93:12)
at _drainQueue (/codebuild/output/src276954272/src/thirdparty-api/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/codebuild/output/src276954272/src/thirdparty-api/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (/codebuild/output/src276954272/src/thirdparty-api/node_modules/bluebird/js/release/async.js:15:14)
at processImmediate (node:internal/timers:464:21)