I'd like to attach a usage plan to throttle per st...
# sst
d
I'd like to attach a usage plan to throttle per stage/routes/etc. CDK allows me to create plans like so
const usagePlan = new apigateway.UsagePlan(scope, id, { name:  "PoorDevPlan",throttle: { rateLimit: 5000 } });
. But how can I attach this to the current Api construct?
Hmm, a workaround is possible if I can grab the underlying cdk construct.
f
@Dennis Dang just to add a bit of context, AWS offers two types of API projects, Rest API and Http API (if you try to create a new API Gateway project in AWS, you are asked to pick one)
d
I believe the one that comes by default with sls framework and SST is the Http API, correct?
f
Http API is the newer offering that’s faster, cheaper, has a better design, but with lesser features.
sst.Api
uses Http API behind the scnene.
yeah
Http Api doesn’t support usage plan at the moment
d
Okay so from this, are you hinting that usage plans are only for the Rest API?
f
yeah
d
Wow, no wonder. Thanks Frank
f
what’s your timeline on this? b/c we are looking to create a construct (ie.
sst.LegacyApi
) that uses the Rest API. Like the discussion you reference.
d
Looking out a couple weeks. I don't think we'd want to switch to the Rest API unless there were other significant wins. This won't block us, since we can at least rely on API Gateway's high but default throttle limits.
f
I found this.. apparently you can configure route-level throttling for Http Api https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-throttling.html
d
I'm looking at that too right now. But the aws-apigateway and v2's api doesn't make it readily accessible. Easy to configure via the console
f
yeah.. it’s not supported by the apigatewayv2 construct yet.. but you can set it at the CloudFormation level https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-apigatewayv2.CfnStage.RouteSettingsProperty.html
if u guys end up blocked by this.. lemme know, I can look into if
sst.Api
can expose something u guys can use to set this
d
That would keep the code really neat if we can configure per route. I'll try the cloudformation path first and share.
d
We're deploying a public-facing sandbox this week so a programmatic way to configure API usage/throttling would go a long way towards helping us sleep at night haha