Adding API to Usage Plan

My serverless.yaml file is as follows:

service: TALib

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

    - deps
    - functions
    - lib

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

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

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.

They are now:


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
limit: 5000
offset: 2
period: MONTH
burstLimit: 200
rateLimit: 100

1 Like

Did you find a solution, is it possible now to add an API to an existing Usage Plan?

Used the AWS CLI with the following command
aws apigateway update-usage-plan --usage-plan-id <PLAN_ID> --patch-operations op=add,path=/apiStages,value=<API_ID>:<API_STAGE>