Adding API to Usage Plan

aws

#1

My serverless.yaml file is as follows:

service: TALib

provider:
  name: aws
  runtime: python2.7
  stage: beta
  region: us-east-1

package:
  include:
    - deps
    - functions
    - lib

functions:
  talib:
    handler: functions/handler.ta_lib_handler
    events:
      - http:
          path: ta
          method: GET
      - http:
          path: ta
          method: POST

I want to add this API to a Usage Plan. How is this done?


#2

As far as I can see, Usage Plans aren’t yet supported by CloudFormation, so there’s no way (that I know of) to do this in Serverless right now.


#3

They are now: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-usageplan.html


#4

Thank you - but can this be defined in the serverless.yml file? I have two different API keys that are associated with different usage plans (one for testing and another for our customer) - but all I see in the example (with no way to associate them is:
apiKeys: # List of API keys to be used by your service API Gateway REST API
- myFirstKey
- ${opt:stage}-myFirstKey
- ${env:MY_API_KEY} # you can hide it in a serverless variable
usagePlan: # Optional usage plan configuration
quota:
limit: 5000
offset: 2
period: MONTH
throttle:
burstLimit: 200
rateLimit: 100