Skip to content

UsagePlan

Source: src/AWS/ApiGateway/UsagePlan.ts

Usage plan for API stages, throttling, and quotas.

Usage plan with stage

const plan = yield* ApiGateway.UsagePlan("Standard", {
apiStages: [{ apiId: api.restApiId, stage: stage.stageName }],
});

Throttled plan with a quota and an enrolled API key

const plan = yield* ApiGateway.UsagePlan("Partner", {
throttle: { rateLimit: 10, burstLimit: 20 },
quota: { limit: 10_000, period: "MONTH" },
});
const key = yield* ApiGateway.ApiKey("PartnerKey", {
generateDistinctId: true,
});
yield* ApiGateway.UsagePlanKey("PartnerLink", {
usagePlanId: plan.id,
keyId: key.id,
});