The AWS API gateway is an excellent front end for lambda functions and other AWS services. However, the default endpoint is a subdomain from amazonaws.com that is not user-friendly. We'll show you how to repair and set up a custom domain.
Requesting a certificate from ACM and Link API Gateway
You need to have the domain name you want to use for the API. You probably want to put this on a subdomain like
api.example.com . There are two things you need to do to do this: Obtain an SSL certificate from AWS Certificate Manager (ACM) to secure API requirements and update your DNS configuration to point to API Gateway.
Log in and go to the ACM console. Select "Request certificate" and enter "Public" as the type.
Next, enter the domain names you want to use for this certificate. You can add multiple domains here, but one is probably enough because the API levels are broken down by sub-URLs anyway.
You have two options for validation. First, you need to update your DNS configuration with a CNAME record. The second will send a confirmation email to the email you have as a contact for the domain. This will not work if your email is not visible from who.is. This happens if you have WhoisGuard protection.
DNS configuration is fairly simple, so we'll go ahead with that. The next screen shows you the name and value of the record you need to write. If you're using Route 53, Amazon's own domain registrar and DNS service, this will be done automatically and you can just click on "Create record in Route 53" to do it for you.
on Route 53. It may take a few minutes for changes to propagate if you use a third-party registrar. After validation, your certificate should change its status to "Issued" and can be linked to the API gateway.
Switch to the API Gateway console and click "Custom Domain Names" in the sidebar. Create a new one, enter your domain name and select the certificate you just created. You also need to make sure that you have selected the correct API type.
. Click Create and a new domain should appear in the list. Click Edit to add a path map. This will link a specific subdomain (e.g.
api.example.com/v1/ ) to the API and level you selected.
It is a good idea to create different paths for different API levels, e.g. For example, a development path for the
$ default stage and a production path for the user-related phase.
After creating, copy the target domain name ”. This is what you need to update the DNS configuration (not the API endpoint itself).
Linking your DNS with the API gateway
At this point you will find that nothing happens when you visit the URL in your browser. The API gateway is configured to use your domain securely, but does not receive any traffic because the DNS does not point anyone anywhere.
Third-party DNS requires you to use a CNAME record. This maps a domain name to another domain name, but requires an additional DNS search. Insert the Target Domain Name value for the custom domain that you set up in API Gateway.
api.example.com CNAME api-id.execute-api.region.amazonaws.com/stage[19659023weiblBeiVerwendungvonRoute53istdieKonfigurationeinfacherSiekönnendengleichenEffektineinerSucheerzielenindemSieeinenA-DatensatzimModus"Alias"verwendeneinenspeziellenDatensatztypmitdemSiedenDatensatzdirekteinemAWS-RessourcennamenzuordnenkönnenWählenSieeinfachdieAPIausderDropdown-ListeausundklickenSieaufErstellen
Changes will take some time to spread, but your API should now be available through your domain name. If it doesn't work, double-check that you are connecting over HTTPS as no insecure connections will be accepted.