What would be the easiest way to make sure I don't exceed costs in a CRUD type AwsGateway/Lambda/DynamoDB/S3/CloudFront type site?

I am creating web app with the following:

* AwsGateway

* Lambda

* DynamoDB

* S3

* CloudFront

What’s the easiest way to make sure AWS doesn’t bill me more than X dollars a month?

And do I need more protection than AwsGateway? (other than the obvious, like authentication via tokens etc)


Related discussions:

One Year of DynamoDB at Timehop
AWS Certificate Manager and CloudFront SSL-Cert-Custom Limits
Can't seem to get CloudFront and SSL working together for custom domain
How does the CloudFormation team prioritize new releases?
Can DynamoDB throughput be shared across multiple tables?
Manage DynamoDB items with TTL
Considering using DynamoDB for my next project - anything I should be aware of?
Using DynamoDB TTLs to get something (money?) for nothing
New – Encryption at Rest for DynamoDB | Amazon Web Services
1 'huge' DynamoDB table -vs- a lot of 'small' DynamoDB tables
Avoiding threshold problems when loading data into dynamodb.
Current best practice for DynamoDB -> AWS Elastic search?
Any guidelines on calculating aggregate fields for analytics/display to users - main data stored in dynamodb.
Best strategy for real-time metrics ingestion and consumption by end-user?
Real time DynamoDB to Redshift updates?
DynamoDb GUI (2018)
Q: What is the best way to store user data? AWS Cognito Custom Attributes vs. DynamoDB
If a user updates a User Pool Attributes how to detect that change and update database (eg. DynamoDB)
DynamoDB Pricing OnDemand vs Provisioned Throughput
DynamoDB has been storing integers as Decimal('234234') and I cannot parse the dictionary
Building a Time Series Database using AWS DynamoDB
Using DynamoDB for a personal blog as a learning project, trying to understand pricing for my ultra-low usage situation
Best way to manage AWS multiple-accounts in projects
Now available--NoSQL Workbench for Amazon DynamoDB (build data models from scratch, or import and modify existing models)
Renaming the Range Key of a DynamoDB table?
Best Practice for Hosting a Client's Site?
DynamoDB modeling question
Syncing a CSV file in S3 with dynamodb ?
ELI5: DynamoDB vs RDS
How exactly are we supposedly to BOTO3’s CloudFront.generate_presigned_url()
Stupid question -- where is the Elasticache Redis API for Java? Or am I misunderstanding what that is?
S3 and Cloudfront web deployment - inconsistent rendering
How to avoid unexpected charges when using AWS free tier
Cognito User Pool: storing user ids & tenant ids
Boto3 help
Not able to find my cloudfront distribution when creating a route53 record. And my zone is greyed out
⚡️ Dynatron - Bridge between AWS DynamoDB Document Client and Real World usage
Minor help with DynamoDB design... Best practices
Single Page App + User Pool(s) + Customer Separation
Thinking of trying Cognito (Web app running on S3 only)
Integration testing AWS services?
Why are DynamoDB Global Secondary Indexes still eventually consistent?
Introducing CloudFront Functions – Run Your Code at the Edge with Low Latency at Any Scale (2021-05-03-#12835)
AWS Free Tier Data Transfer Expansion – 100 GB From Regions and 1 TB From Amazon CloudFront Per Month
Do I need encryption here?
What does the architecture of the Cloudtrail service look like
DynamoDB Key Partition Strategies for SaaS
Using cloudfront to private origin
Anyone doing geospatial queries? NoSQL? Amazon Location Service?
dynamodb - design sparse index for chat based app?
Why is limit for number pf AWS managed policies is so small?
Is it just me, or does serverless involve way less code, on average, than the alternatives?
In dynamodb, what is better: 1 fat document or many small documents??
Internal Static Site served to IAM users
where to learn from scratch
Dynamodb partitions
How to handle concurrency in dynamodb?
DynamoDB Price changed recently?
Why does dynadmoDB BatchGetItem accepts keys as Map, List, SS, NS, BS?
DynamoDB: GSI & Sort Key
MongoDB vs DynamoDB
How to choose between ALB + ECS and VPC Lattice + ECS?
DynamoDB or Aurora or RDS?
How to Allow Only CloudFront to Access My Application Load Balancer?
How do Dynamodb outages affect TTL?
Kinesis worker has no lease assigned
Best resources to learn DynamoDB in 2025?
How do you properly name DynamoDB index names?
S3 Incomplete Multipart Uploads are dangerous: +1TB of hidden data on S3
Global cloudfront issues
DynamoDB single-table pattern: SaaS Multi-Tenant with 10 access patterns, 1 GSI (full breakdown)
Just passed the AWS Solutions Architect Associate Exam!! Some suggestions
Free labs on Qwiklabs
Amazon CloudFront Tutorial: Learn how to create CloudFront Distribution hands-on
Passed AWS SAA-C01 with 926/1000
How should one answer this DynamoDB question?
How can this question / answer possibly make sense on Stephane's SSA-C02 section quiz
Passed Developer Associate Exam!
Cleared SAA-CO3.
SAP-C02: Conflicted about this question: DynamoDB Provisioned vs OnDemand scenario
weird ELB/Route 53 issue
How do you guys keep track of all the steps in AWS labs?
Is there a way to limit the read units for Querying a DynamoDB table to just 1 per second?
Which is speedier AWS Cloudfront or Cloudflare?
Cloudfront - Limit locations
Is EC2 really the right choice for hosting web applications?

Budgets, create alerts that notify you when you go over a certain threshold.

Create an AWS Budget with alerts at multiple thresholds (e.g. 50%, 80%, 100%).
This won’t stop spend, but it ensures you know immediately if something is off.

This is necessary but not sufficient on its own.

the easiest way is to not use aws… seriously you have a basic crud app. use a $10 vps, or if thats too small a dedicated server… or if you outgrow 1 server a load balanced cluster of dedicated servers… its cheaper than most people realize

Note that you didn’t account for cloudwatch logs, which can quickly be expensive, and also the various network costs ( outgoing, inter az, public ipv4, … )

You can’t “make sure AWS doesn’t bill more than X dollars a month”, it’s impossible, by design.

First you can’t set spend limit

Second all the cost explorer / budgets etc have 24 hour delay so if you have for example a huge traffic spike you will know its cost a day later. So even if you make triggers which remove everything after a certain budget is reached, it will happen with a significative delay.

You can look into lambda function urls and see if it fits your usecase

You can’t hard-cap AWS spend, but you can get close: set AWS Budgets with alerts, use CloudWatch alarms on Lambda/API Gateway usage, and put sensible service limits/throttles. For protection, API Gateway + auth is usually fine, but add WAF if it’s public-facing to stop bots from racking up calls. In my experience, most surprise bills come from missing throttles not “hackers”, so might not be an issue you need to think too much about.

sounds like a good stack.
Maybe if you’re in a VPC think about putting gateway endpoints (dynamodb and s3)

if you have cloudfront you can skip api gateway and directly use lambda origin.

This. Lightsail you can get like 4TB of transfer for nothing. If it’s really just low cpu crud. You might have to add some storage. Light sail is garbage if you need more CPU but for me it’s been great.

Sorry, but these are awful suggestions.

VPC for services that natively are public? Cloudfront directly to Lambda when the only path for that are function URLs?

API Gateway offers a much cleaner architecture, features, and security than naked function URLs at very little cost. The OP’s stack is fine.

If you add an API key to your API Gateway and add it as a custom x-api-key header in your CloudFront origin requests, you can use the Usage Plan of API Gateway to effectively cap your total requests per time period.

A crude, but would effectively allow the site to handle upto X amount of traffic in a month and then automatically shut itself down until the next billing cycle.

…

never heard of network isolation? Maybe you are using libraries you open yourself for supply chain attacks. Having the code run inside an environment with unrestricted internet access is a security risk.

For Cloudfront → Lambda directly there are arguments for and against it. Just putting it of as bad advice is bad advice.

For this stack what workload is running in your VPC?

While you can attach your Lambda to your VPC, but that’s largely to facilitate communication with other workloads in the VPC (EC2, RDS, etc). In this stack the only endpoints mentioned are public, which is why you’re now advocating adding gateway endpoints back in to bandaid over the problem you created.

I mean sure, your Lambda traffic to S3/DynamoDB traffic is now secured over AWS’s network…but that’s the case already w/o the VPC for traffic between Lambda and S3/DynamoDB. So you haven’t actually added any additional network isolation or security, just complexity for the sake of theatre. Again, I don’t see what actual problem you’re solving in this stack by adding the relatively large complexity and attack surface of a VPC, for this stack.

VPCs are free

Can you please tell AWS that? They’re currently charging me $20k / month for VPC service charges alone.

For Cloudfront → Lambda directly there are arguments for and against it. Just putting it of as bad advice is bad advice.

There’s some edge cases, yes. Mostly at very high scale. API Gateway offers so much control, flexibility, and simplifies architectures and code so much for very little if any cost that there’s little reason to go raw dogging with function URLs.

But at least function URLs are not an invalid design choice, just not ideal for most situations. Unlike suggesting VPC for this stack, which is indisputably a mistake.

VPC without internet gateway and nat is free dude…

I’ve decided to stop defending myself - it seems you are persistent in your opinion.

If you want to skip free security go for it.
Please check VPC pricing again, VPC without any VPC services is free and it’s the only thing required. Just don’t add a NatGW..

That’s a shame.

But to be clear for others that stumble upon this subthread:

There is no added security with VPC for this stack design because there’s no more network isolation going through VPC than there is in the base service layer between Lambda and S3/DyamoDB: Both patterns are 100% on AWS’s backend network.

Even if you use a VPC for your Lambda the major “public” network leg is CloudFront to Lambda and that can’t be done over VPC even using CloudFront VPC Origins without additional layers. Function URLs won’t work here, they are only public.

API Gateway again is an option for that extra layer, although it too is not fully network isolated as you’re advocating for. Really you’d need a VPC private ALB for the CloudFront VPC Origin to terminate to and front Lambda, but again the ALB to Lambda is reaching out to the public Lambda endpoint unless you use an Interface endpoint.

All that and your core data stores…S3 and DynamoDB…are still exclusively public services.

Without all the extras you’re calling for this is TLS/SigV4 traffic exclusively within AWS’s network. And that’s exactly the same isolation as would exist with your VPC suggestions.

I’m not anti-VPC; I run thousands across my network. But they aren’t a golden hammer. My primary PCI-DSS stacks for example, are 100% serverless without any VPC and they’re fully in compliance.

what a bad opinion regard to VPC, you should do the networking certification

I give you a hint. What happens if due to a misconfiguration your lambda that reads form dynamodb leaks access/secret access key - and how would you mitigate that.

Second hint: What happens if your lambda contains a malicious dependency that posts your secret to an external server?

Why would you be using an access/secret for DynamoDB auth from Lambda instead of the Lambda’s execution role?

But I will grant you there is a minor concern for temporary credentials being exfiltrated and exploited in the short expiration window. Point taken.

*edit
Also I’m a bit worried - why do you run thousands of VPCs?
** edit

Because we’re a F500 with a very global footprint across hundreds of subsidiaries and like you said before, network isolation is groovy. In large organizations you rarely get luxury of running a perfect configuration, especially if you’re as M&A busy as we are.

As much as possible I strongly subscribe to the Account per application/env organizational model, given that the only real resource container AWS provides is the Account. The app/env owns its own VPC, if using one, with no first class connectivity to the corporate WAN: No TGW, peering, etc. If the app/env needs to publish or subscribe to some other service in the company then PrivateLink is the goto choice.

Clean separation of concerns, clean well defined blast radius, clean billing, clean access controls, etc. But that alone means even the most trivial of backoffice app is likely to have two to five VPCs between dev, cicd, test, and prod environments, and that’s before we get into GDPR facing systems where we have to deploy multi-region for data sovereignty reasons. But like you said, VPCs are free right? :slight_smile:

As I say this the vast majority of our workloads run in a small number of large, WAN connected VPCs (TGW, etc) with little if any isolation; Legacy tech debt from a raw lift+shift of the datacenters to the cloud that we’re working through. But new workloads and refactored workloads are getting the full treatment. Rome didn’t fall in a day.

> Why would you be using an access/secret for DynamoDB auth from Lambda instead of the Lambda’s execution role?

Guess you don’t know how the credentials chain in AWS Lambda works…

> Why would you be using an access/secret for DynamoDB auth from Lambda instead of the Lambda’s execution role?

Temp credentials in AWS Lambda are made available through access/secret key inside an Env Variable…