Enhance API Client Experience by Deploying a CloudFront Distribution to Serve APIs from Amazon API Gateway

Just like you speed-up delivery of your static assets from S3 buckets using CloudFront CDN, you can do the same for your APIs as well. In most cases, it’s enough to make your API “edge-optimized”:

If you do this, API Gateway creates & manages a CloudFront distribution for you behind the scenes, but if you need more control over CloudFront, leave the Endpoint Type of the API as Regional & create a CloudFront distribution as shown below:

The Origin Domain Name is the API endpoint you get when you deploy the API to a stage & the Origin Path is the stage name:

Wait 15-20 minutes for the CloudFront distribution to be deployed. You can then hit your API using the distribution endpoint:

The above test is using an API backed by a Lambda function which simply returns the Event object it gets from API Gateway. Since Authorization & query parameters are required by most APIs, it shows that both of these worked as expected!

Also see — How do I set up API Gateway with my own CloudFront distribution?.