Mapping custom domain to GCP API Gateway - google-cloud-platform

I've set up an api using GCP API Gateway to map api calls to multiple Cloud Run services but now I need to point a custom domain to the API gateway. I see that there's no option to do so like in Cloud Run and I also tried setting a CNAME record pointing to the gateway's url but I didn't work.
Is their anyway I can set the domain name of the gateway?

As advised on the relevant section of the documentation:
Custom domain names are not supported for API Gateway. If you want to customize the domain name, you have to create a load balancer to use your custom domain name and then direct requests to the gateway.dev domain of your deployed API.

Related

API Gateway: Mixing of REST APIs and HTTP APIs on the same domain name can only be accomplished through API Gateway's V2 DomainName interface error

I have created a sample API Gateway using "HTTP API".
I then add a custom domain and added the relevant CNAME record to the DNS.
I then go on Configure API mappings, to add the HTTP API but I get the following error message:
Mixing of REST APIs and HTTP APIs on the same domain name can only be accomplished through API Gateway's V2 DomainName interface. Currently, WebSocket APIs can only be attached to a domain name with other WebSocket APIs. This must also occur through API Gateway's V2 DomainName interface.
Note that adding normal "REST API" works fine.
What is the problem exactly and how do I fix it?
Note that I have since deleted all custom domains, and added this domain fresh, and it still does not work..
I got a second error message and this may explain the reason:
The error message says: "These API types may only be associated to REGIONAL domain names": this means that an HTTP API can only be associated with a REGIONAL custom domain so EDGE is not (hopefully yet) supported with EDGE custom domains.
You only have the option to use a REST API, in order to associate it with an EDGE custom domain, or to create multiple HTTP API deployments in multiple AWS Regions and use Route53 (or you own DNS provider) to map each regional deployment endpoint based on a low-latency strategy.

AWS Route 53 with AWS API Gateway

Currently I have many AWS Lambda deployed already. And then I think of how to perform Performance Test for each of AWS Lambda. The solution I decided to go is
- Expose each API using AWS Api Gateway for each AWS Lambda
- Use JMeter (Neoload) to perform "performance test" for an API.
The approach is working fine except we need to use a generated endpoint from AWS like https://tl8drdruob.execute-api.us-west-1.amazonaws.com/dev. Now I would like to see if we can use Route 53 to route API or not.
We do have an host zone like abc.awsnonprod.mycompany.net. And I trying to add a record set to that host zone but I don't see any my API Gateway end points listing on Alias Target (API Gateway).
Please advice me if I missing something here.
Thank you
It seems you need to have the custom domain name to map the route 53 to API Gateway.
Please follow Set Up a Custom Domain Name for an API in API Gateway
The API Gateway custom domain feature is very likely what you want. It will create a special/internal Cloudfront distribution which you can use to manipulate the domain and path. You can even relate it to API Gateway stages. Then you could use Route 53 to CNAME or A (alias) your custom domain to the CloudFront distribution.

AWS- I have a CFT that integrates a Lambda Function with API Gateway. What resources do I use to connect my API Gateway to a Custom DNS name?

So I want something like
"example.com/helloworld" to display the Hello World message I have stored in my Lambda Function. My CFN creates a Lambda Function, and creates an API, then connects both of these services.
However, I don't know what resources to use to connect my API Gateway to a Custom DNS name like "example.com/helloworld" so I can display "Hello World" from my Lambda Function in a browser. What resources do I need here?
First step is to go to the "Custom domain names" section of your API Gateway and configure a domain for a particular API and stage. This will instruct the CloudFront distribution that serves your API (API Gateway is always served by a CloudFront in the background) to accept network requests for that domain and forward them to a particular stage (e.g. testing or production). This way you can have different domains instead of URL paths for different stages and use just the endpoint (part after the stage) of the URL.
Then you need to own a domain name (e.g. example.com) and point your domain's CNAME record to the domain that you get when you configure your API Gateway's custom domain.
If your domain is hosted on the AWS Route53 service, you can create just an ALIAS for the domain given to you by the API Gateway instead of the CNAME.
If you are asking for Cloud formation resource for connect APIGW to custom domain name ( or creating a custom domain name in APIGW ) - it is AWS::APIGateway::DomainName
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-domainname.html

Point CNAME record to API Gateway Endpoint host?

I have a deployed API Gateway Regional Enpoint in the form of:
https://some-id.execute-api.us-east-1.amazonaws.com/prod/my-path/
I know that in order to have a custom domain like www.my-domain.com resolve to https://some-id.execute-api.us-east-1.amazonaws.com/prod/my-path/ I must setup an api gateway custom domain and cloudfront distribution.
However, I'm only interested in having www.my-domain.com resolve to some-id.execute-api.us-east-1.amazonaws.com (without the path). This is so I don't need to update my clients if the deployment id changes.
I tried setting up a Route53 CNAME record with the value of some-id.execute-api.us-east-1.amazonaws.com for api.my-domain.com but it doesn't work.
I believe you just need to leave your custom domain without a base mapping. From the AWS documentation:
If you do not set any base mapping under a custom domain name, the resulting API's base URL is the same as the custom domain (e.g., https://api.example.com.) In this case, the custom domain name cannot support more than one API.

What is the difference between a Custom Domain Name at the API Gateway and a CloudFront Instance with a Custom Domain?

I'm currently extensively using the API Gateway as a source for CloudFront. My CloudFront serves other things as well, such as plain files from S3.
I've recently been looking into improving the current setup, and noticed the "Custom Domain Names" option in API Gateway.
From what I've understood, using it creates an unconfigurable CloudFront instance. I've not been able to find much information beyond that.
Are there any advantages to using API Gateway's Custom Domain Names over using a self-managed CloudFront instance?
When you use AWS CloudFront you can configure different Origins such as S3, API Gateway & etc to the distribution which allows to serve different services through same domain. e.g you can serve mydomain.com points to index.html in S3 and mydomain.com/api/* points to API Gateway. This allows for the frontend JavaScripts to access the API without the need for Cross Origin Request support at API Gateway which avoids sending Options preflight(If you have headers like Cookie, Authorization & etc.) request by the browser.
On the other hand you can configure Custom Domain Names to API Gateway. This allows to define a Custom Domain as well as a Custom SSL Certificate using AWS Certificate Manager. The main difference is, if you have a frontend application, you need to define two domains(or different subdomains) for the frontend served from S3 and API. When accessing the API from different domain it will require to have CORS configured at the API Gateway and can affect performance based on the latency.