How to assign api keys for Gateway events in functions

I have created two API KEYS and one API NAME like below

provider:
  name: aws
  runtime: nodejs12.x
  memorySize: 512
  stage: ${opt:stage, 'dev'}
  apiKeys:
    - name: apiKey-1
    value: ${self:custom.apiKey}
    - name: apiKey-2
    value: ${self:custom.apiKey}
  apiName: CF-API

functions:
  funcA:
    handler: src/handlers/funcA.handler
    name: ${self:provider.stage}-funcA
    events:
      - http:
        method: any
        path: /gatwayforAPIKEY-1
        private: true
  funcB:
    handler: src/handlers/funcB.handler
    name: ${self:provider.stage}-funcB
    events:
      - http:
        method: any
        path: /gatwayforAPIKEY-2
        private: true

Now how can I assign the API KEYS to the functions?
I want to assign apiKey-1 to the funcA gateway and apiKey-2 to the funcB gateway

1 Like