DianaIonita / serverless-api-gateway-throttling

A plugin for the Serverless framework which configures throttling for API Gateway endpoints.
ISC License
69 stars 7 forks source link

Handle dry-run deployments #8

Open scadu opened 3 years ago

scadu commented 3 years ago

Hi,

@DianaIonita, at the beginning, I would like to thank you for the plugin.

I started using it a while ago and noticed that the plugin doesn't handle dry-run deployments – it expects RestApiIdForApigThrottling key from CloudFormation's output while it's not available since there was no changes applied. I used to use dry-run deployments as a form of validation, so I'm wondering if it's viable to handle this case and how it could be done.

DianaIonita commented 3 years ago

Hi @scadu,

Would you mind describing what you mean by dry-run deployment? Is there a specific set of serverless commands you run?

Thanks

scadu commented 3 years ago

Hello @DianaIonita,

The exact command I use is: sls deploy --noDeploy --stage somestage

DianaIonita commented 3 years ago

Hi @scadu,

The way the plugin works is that it hooks into the event after:aws:deploy:finalize:cleanup and runs the command to update the stage for the API Gateway deployment. That only works if the service has already been deployed. Since the sls deploy --noDeploy command only creates the deployment package, there aren't any throttling settings for the plugin to update.

There might be a way to update the CloudFormation generated by the Serverless framework, instead of updating the stage post-deployment. At a glance, I think the stage description on the AWS::ApiGateway::Deployment would need to be updated with throttling settings, then probably each individual method would need to be updated as well. However, there are currently no plans to support this feature.

Thank you for raising the question!

scadu commented 3 years ago

@DianaIonita, indeed, this would be quite hackish anyway. Thanks for clarifying.