DianaIonita / serverless-api-gateway-caching

A plugin for the Serverless framework which helps with configuring caching for API Gateway endpoints.
ISC License
136 stars 35 forks source link

Does not work with "serverless-aws-alias" plugin #69

Closed ValeryP closed 4 years ago

ValeryP commented 4 years ago

I've realized that the plugin does not work for aliases. Every time I deploy to any alias it performs all actions on the stage instead of alias name.

Plugins:

plugins:
  - serverless-python-requirements
  - serverless-aws-alias
  - serverless-api-gateway-caching
  - serverless-api-gateway-throttling

Fun:

functions:
  energy:
    handler: src/handler.energy
    package: {}
    events:
      - http:
          path: energy
          method: get
          cors: true
          private: true
          caching:
            enabled: true
            clusterSize: '0.5'
            ttlInSeconds: 60
            perKeyInvalidation:
              requireAuthorization: true
              handleUnauthorizedRequests: Ignore
            cacheKeyParameters:
              - name: request.header.x-api-key

Am I doing something wrong or is there any workaround? Thanks!

DianaIonita commented 4 years ago

Hi @ValeryP,

Thanks for raising this issue. I had a quick look at the serverless-aws-alias plugin and caching seems to work, but only for the masterAlias - the primary stage as API Gateway calls it. I do realise that the reason for using the serverless-aws-alias plugin is to enable you to deploy to multiple aliases, so this finding may not be useful to you.

There are many plugins out there, which is great. I'm keen on supporting serverless-api-gateway-caching so that it stays compatible with the latest version of the Serverless framework, but it would be very time-consuming to add support for other plugins and ensure consistency across time. Hopefully, the Serverless framework will start supporting multiple stages in an API Gateway soon, at which point I'll revisit this feature.

Best, Diana

DianaIonita commented 4 years ago

Also, it looks like you can configure caching settings as part of the serverless-aws-alias plugin: https://www.npmjs.com/package/serverless-aws-alias#the-aliasstage-configuration-object - hope this solves your problem.