Iggy Green
Iggy Green

Reputation: 5

API Gateway Is it possible to set a custom domain name for API Gateway and integrate it with a new CloudFront?

My API endpoint type is edge-optimized. I have a custom domain name API like www.example.com and I want to add a new CloudFront which to block specific countries request in front of my API Gateway.

How to add a new CloudFront in front of my API Gateway and use the same domain name (www.example.com)? I am confused. Is it possible to do that?

Any advice will be appreciated.

Upvotes: 0

Views: 720

Answers (1)

gayashanbc
gayashanbc

Reputation: 1024

Yes it is possible to do that. You should follow the following steps.

  • Create a origin for your API Gateway inside your CloudFront distribution. There you should enter the endpoint of your API Gateway for the origin domain name.
  • Then you need to create a behavior inside the CloudFront distribution which forwards requests that match a specific path pattern to your API Gateway. (Make sure that you put the Minimum TTL to as 0, since we don't want to cache the the API requests)

See the following documentation for further reference.

Custom origins

Cache behaviors

Upvotes: 2

Related Questions