Closed takeda closed 3 years ago
So I figured out a workaround, but it would be nice if that was not needed, since it's ugly.
For anyone else who has this issue I did it by adding the following custom resource:
resources:
Parameters:
ApiGatewayRestApi:
Type: String
_ Default: n/a
Then used serverless-plugin-ifelse to exclude resources.Parameters.ApiGatewayRestApi
for normal situations when ApiGateway is available.
Hi @takeda
Thanks for raising this issue. Would you mind providing some of your serverless.yml
configuration please? I'm specifically curious how you define regions with the if-else plugin and how you configure throttling using this plugin.
so basically the relevant parts look like this:
[...]
resources:
Parameters:
ApiGatewayRestApi:
Type: String
Default: n/a
plugins:
- serverless-api-gateway-throttling
- serverless-plugin-ifelse
[...]
custom:
apiGatewayThrottling:
maxRequestsPerSecond: 10
maxConcurrentRequests: 5
serverlessIfElse:
- If: '"${self:provider.region}" != "us-east-1"'
Exclude:
- functions.API
- functions.ScanImages
- functions.PrepareDatabase
ElseExclude:
- resources.Parameters.ApiGatewayRestApi
The API
function is the one getting the REST requests. ScanImages
and PrepareDatabase
are just simple lambdas. By excluding these functions the lambdas are not created and in case of functions.API
that includes the API Gateway.
Hi @takeda,
Thanks for the extra info. The latest version of the plugin, 1.1.1, should now have fixed this issue. Please reopen if that's not the case.
So this is kind of weird request, because why would I need this plugin if I'm not using API Gateway.
What I'm doing is actually using serverless-plugin-ifelse so I can deploy my project in two regions. In one of the regions I'm disabling the API gateway, and only have lambdas running based on events.
The problem is that your plugin tries to be helpful and also exposes
ApiGatewayRestApi
in theOutputs
section. The problem is that on the region where I have API disabled theApiGatewayRestApi
doesn't exist and I'm getting following error:The CloudFormation template is invalid: Unresolved resource dependencies [ApiGatewayRestApi] in the Outputs block of the template
Is there a way to disable this functionality?