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

[serverless-api-gateway-caching] No Rest API found. Caching settings will not be updated - when used in conjunction with serverless-nested-stack. #48

Closed kkirov closed 3 years ago

kkirov commented 5 years ago

The serverless-nested-stack breaks down the stacks in few nested stacks to avoid the cloudformation limitation of 200 resources per stack. And when I use serverless-nested-stack breaks and serverless-api-gateway-caching I get: Serverless: [serverless-api-gateway-caching] No Rest API found. Caching settings will not be updated.

It seems to me that the code: https://github.com/DianaIonita/serverless-api-gateway-caching/blob/develop/src/restApiId.js#L15 is not checking in all nested stacks if resource 'ApiGatewayRestApi' exists! Let me know if you need me to provide any additional information!

willfarrell commented 5 years ago

What's the order of your plugins? Order matters.

kkirov commented 5 years ago

but I also tried:

and I get the same result.

webchaz commented 5 years ago

I'm getting this same issue using serverless-plugin-split-stacks have also tried multiple order for including these. Any chance you found a solution to this?

simqel commented 5 years ago

For now, the only solution that I've found is to set restApiId and restApiRootResourceId manually:

provider:
  apiGateway:
    restApiId: xxxxx
    restApiRootResourceId: xxxxx

How to get them: https://serverless.com/framework/docs/providers/aws/events/apigateway#manually-configuring-shared-api-gateway

Can be also set separately for stages using custom section and variables.

chaitanya11 commented 5 years ago

I am also facing same issue when used with serverless-plugin-split-stacks.

majoraze commented 4 years ago

Same issue using serverless-plugin-split-stacks. Any solution rather than setting the restApiId manually?

majoraze commented 4 years ago

Actually I found this package that I believe is a fork of this one and it's working: https://www.npmjs.com/package/serverless-api-gateway-caching-split-stack

All I have to do (after spent some time looking at the code) is add this configuration:

apiGatewayCaching:
    forceEnable: true

And changing the plugin to: - serverless-api-gateway-caching-split-stack

Maybe someone can merge this in this repo?

BorjaMacedo commented 4 years ago

If you are using split stack you need it to place the AWS :: ApiGateway :: RestApi resource in the root. To cause that you need to use the file stacks-map.js.

if (resource.Type.includes('AWS::ApiGateway::RestApi')) {
            return false;
}

Be careful, returning null or undefined is not enough.

DianaIonita commented 3 years ago

The latest version of the plugin, 1.7.3, now has an improved way of finding the Rest API id, which should make it work with stack splitting plugins. The changes applied are in this PR if anyone is curious.

Please feel free to reopen the issue or raise a new one if you're still having problems.