Logo

dev-resources.site

for different kinds of informations.

Using a custom domain name in a Private REST API Gateway

Published at
6/6/2024
Categories
aws
apigateway
route53
lambda
Author
mkreder
Categories
4 categories in total
aws
open
apigateway
open
route53
open
lambda
open
Author
7 person written this
mkreder
open
Using a custom domain name in a Private REST API Gateway

When working on internal networks, particularly within a VPC, developers often encounter the need to interact with a private API gateway. A common scenario is when a network resource, which must make non-internet HTTPS calls without involving the AWS API, requires access to a specific lambda function. While using the API gateway assigned hostname is an option, opting for a private DNS name can provide a more consistent approach across environments.

According to the AWS Documentation: "Custom domain names are not supported for private APIs."
However, there is a simple hack to get this to work.

TL;DR; Architecture

Image description

Full Solution

  1. On the VPC, create a "execute-api" VPC endpoint for API Gateway
  2. On API Gateway, create a private REST API and all necessary/ resource methods. Create a resource policy that only allow access through the VPC Endpoint
  3. On the VPC Endpoints, explore the Subnets section of the VPC endpoint created in step 1 and grab the IPs
  4. Create a TLS target group using the IPs from step 3.
  5. Create a TLS internal NLB, using the target group from step 4.
  6. Create a custom domain name in API Gateway (Regional type) but point it to the private API gateway.
  7. On Route53, configure a private zone attached to the same VPC with a CNAME record that points to the NLB DNS address.

Once this is done, it should work. I have done this many times in different projects but keep forgetting about it, so I figured it was a good time to document it to be useful for someone else.

route53 Article's
30 articles in total
Favicon
Dominio personalizado en Amazon API Gateway. Dominio desde GoDaddy.
Favicon
How to Simplify DNS Management in a Multi-Account Environment with Route 53 Resolver
Favicon
How to Add an Elastic (Static) IP to Your EC2 Instance And Update Your DNS Records on Route53
Favicon
Amazon Route 53: AWS's Powerful DNS Service πŸŒπŸš€
Favicon
AWS Private Zones To The Max
Favicon
Migrate a hosted zone to a different AWS account in few seconds!!
Favicon
Before You Dive into Route 53: Learn These DNS Terms
Favicon
How to Add DNS Records for Your Domain in Route53
Favicon
How to Set Up a Public Hosted Zone on Amazon Route 53 When Your Domain Is Registered with Another Registrar
Favicon
Convert http to https in AWS
Favicon
Amazon Route 53 Resolver endpoints now support DNS-over-HTTPS (DoH) with Server Name Indication (SNI) validation
Favicon
Automated DNS Record Management for Kubernetes Resources using external-dns and AWS Route53
Favicon
Automating AWS DNS Firewall Domain List Updates Using S3, Lambda, and CLI
Favicon
Issue 65 of AWS Cloud Security Weekly
Favicon
Unlocking the Power of AWS Route 53: Your Complete Guide to DNS Management
Favicon
How to Use AWS Route 53 for Free
Favicon
Setup AWS EC2 and Configure Route 53: Domain Redirection Made Easy!
Favicon
Deploying Static Website to AWS: A Step-by-Step Guide with S3, Route 53, and CloudFront
Favicon
Cross-Account VPC Associations with Route53 Private Hosted Zone and Addressing Terraform State Update Issue
Favicon
AWS Route53: A Beginner’s Guide
Favicon
Configuring a Custom Domain for API Gateway with AWS Cloud Development Kit (CDK): SSL Certificate Use and Route 53 Integration
Favicon
How to Host a Static Website on AWS Using S3, Route 53, CloudFront, and Certificate Manager
Favicon
Managing your GoDaddy domain with Route53
Favicon
Using a custom domain name in a Private REST API Gateway
Favicon
How to migrate DNS records from CloudFlare to AWS Route53 with Terraform&Terragrunt
Favicon
Multi-Account/Environment DNS Zones
Favicon
Creating a custom domain name for AWS Elastic Beanstalk application
Favicon
Failover Mechanism in Amazon Route 53 Private Hosted Zones
Favicon
Free dynDNS for your NAS: auto-update DNS with your latest IP
Favicon
Advanced Techniques in AWS API Gateway and Route 53

Featured ones: