I guess you are mixing up the ways in which we configure api keys with and without the serverless-add-api-key plugin. Following is a working serverless.yml without using the plugin.
service: serverless-api-key
provider:
name: aws
stage: prod
timeout: 30
runtime: nodejs12.x
apiGateway:
apiKeys:
- MyKey
functions:
hello:
handler: handler.hello
events:
- http:
path: /hello
method: get
sls deploy output below -
Service Information
service: serverless-api-key
stage: prod
region: ap-south-1
stack: serverless-api-key-prod
resources: 14
api keys:
MyKey: Aeeblv4djg2AmlXXXXXXXXXXXXXX2fk9l4iCDRf
endpoints:
GET - https://xxxxxxxx.execute-api.ap-south-1.amazonaws.com/prod/hello
functions:
hello: serverless-api-key-prod-hello
layers:
None
If you still want to use the plugin, you need to get the correct syntax. You can use the below serverless.yml -
service: serverless-api-key-2
plugins:
- serverless-add-api-key
custom:
apiKeys:
- name: MyKey33
provider:
name: aws
stage: prod
region: ap-south-1
timeout: 30
runtime: nodejs12.x
functions:
hello:
handler: handler.hello
events:
- http:
path: /hello
method: get
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…