Skip to content

Do requests to a disabled default API endpoint get billed?

0

I’m trying to confirm the billing behavior of Amazon API Gateway when the default execute-api endpoint is disabled (for REST APIs). Disabled endpoint documentation: https://docs.aws.amazon.com/apigateway/latest/developerguide/rest-api-disable-default-endpoint.html

My goal is to disable the default endpoint and use a custom domain instead. The custom domain will be protected by Cloudfront/WAF a part of a Cloudfront fixed rate price plan. However, if a request is made directly to the disabled default endpoint and results in a 403 (or similar) response, is the request still counted as “received” by API Gateway for billing purposes?

The API gateway pricing docs don't make this very clear. The docs: https://aws.amazon.com/api-gateway/pricing/

I'd really like to know as I haven't found any clearly documented ways to completely stop bad actors from blowing up someone's AWS bill via API gateway spam. Yes, I could protect it using WAF, but someone could still spam the API and increase someone's AWS bill via WAF costs, and I wouldn't be able to use the WAF a part of a Cloudfront fixed rate price plan to protect the API gateway (the WAF can only be used for the Cloudfront distribution).

Thanks!

asked 10 months ago328 views

3 Answers
1

Yes, requests to the disabled default execute-api endpoint are still billed by API Gateway as "API calls received," even if they return 403 Forbidden.

Disabling the endpoint only changes the response code; it does not prevent the request from hitting API Gateway and being counted for billing.

Billing details:

API Gateway charges per API call received (first million free/month, then tiered ~$3.50/million in US East), regardless of:

  1. HTTP status code (200, 403, 500, etc.)
  2. Whether the default endpoint is disabled
  3. Authorization failure

Data transfer out (if any response body) is also charged (~$0.09/GB).

answered 10 months ago

0

When you disable the default endpoint for an API Gateway REST API, clients can still connect to the endpoint but will receive a 403 Forbidden status code. According to Amazon API Gateway's pricing model, you pay only for the API calls you receive and the amount of data transferred out.

Since the request to a disabled default endpoint is still received and processed by API Gateway (even though it results in a 403 response), these requests would still be counted as API calls for billing purposes. The pricing is based on the API calls received, regardless of the response code returned.

After disabling the default endpoint, you'll need to redeploy your API for the change to take effect. This ensures that clients can only access your API through your custom domain name, if configured.
Sources
Disable the default endpoint for REST APIs - Amazon API Gateway
Amazon API Gateway Pricing

answered 10 months ago

0

Amazon CloudFront provides a clear precedent: requests blocked by AWS WAF do not incur CloudFront charges. Effective October 25, 2024, all CloudFront requests blocked by AWS WAF are free of charge, meaning CloudFront customers never incur request fees or data transfer charges for requests blocked by AWS WAF, refer [1]. AWS WAF continues billing for evaluating and blocking these requests, but the underlying service (CloudFront) does not charge for the blocked traffic.

Additionally, when using CloudFront flat-rate pricing plans, blocked DDoS attacks and requests blocked by AWS WAF never count against your usage allowance. Refer [2]

[1] https://aws.amazon.com/about-aws/whats-new/2024/11/amazon-cloudfront-charges-requests-blocked-aws-waf/

[2] https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/flat-rate-pricing-plan.html

The ideal approach would be:

  1. Use a regional API Gateway endpoint with a custom domain
  2. Place CloudFront in front of API Gateway with a flat-rate pricing plan
  3. Configure CloudFront to insert a custom header or API key that API Gateway validates
  4. Use AWS WAF at the CloudFront level to block malicious traffic before it reaches API Gateway
  5. Configure rate limiting in both CloudFront/WAF and API Gateway

This architecture ensures that malicious traffic is blocked at the CloudFront edge with predictable costs under the flat-rate plan, and requests blocked by WAF don't incur CloudFront charges.

Comment here if you have additional questions, happy to help.

-- Abhishek

AWS
EXPERT

answered 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.