Create SaaS Subscriptions Usage Plans w/o API Key

Hi all,

What is the best way to create usage plan monthly quotas without API keys ( for example free tier, paid tier monthly function limits. free tier =10 paid tier =100)? Would the best way be to create another DynamoDb table to use as a token bucket and have a function that checks the amount of tokens left for each user (cognito) before the page loads?

Generate API keys upon successful subscription and store them in a DynamoDB table along with the current expiry date. Create an API to fetch URLs for the desired files, not the files themselves. Use API Gateway for this API and implement a custom authorizer that will hit your DDB table and verify the key is still valid. Then the API will create a presigned URL for the desired object in S3 and return that to the user. The user will then use the presigned URL to fetch the actual contents of the file jpg to pdf directly from S3.