Skip to content
Haiko edited this page Jan 8, 2018 · 2 revisions

HOWTO

How to create a custom domain for AWS API Gateway

For a regional API, use the AWS CLI to create an ALIAS record set in the Route 53 hosted zone. See AWS Doc for more info. Important is to differentiate two different HostedIds: the one from your hosted zone in Route 53 and the Hosted Zone Id from the Region.

Using the AWS CLI

aws route53 change-resource-record-sets 
    --hosted-zone-id {your-hosted-zone-id}  --> use your hosted zone from Route 53
    --change-batch file://path/to/your/setup-dns-record.json

file example

{
  "Changes": [
    {
      "Action": "CREATE",
      "ResourceRecordSet": {
        "Name": "regional.example.com",
        "Type": "A",
        "AliasTarget": {
          "DNSName": "d-numh1z56v6.execute-api.us-west-2.amazonaws.com",
          "HostedZoneId": "Z2OJLYMUO9EFXC", //--> regional hosted zone id, see also [AWS Doc](https://docs.aws.amazon.com/general/latest/gr/rande.html#apigateway_region)
          "EvaluateTargetHealth": false
        }
      }
    }
  ]
}
Clone this wiki locally