Getting a subdomain (not Route 53) to point to private api gateway associated with a VPC (/without Host Headers)?
I encountered a strange bug at work while working with a private api gateway associated with VPC endpoint, and I was wondering if anyone had any insights/solutions?
Details below:
-
From my DNS provider (not Route53. Example: Namecheap), I am trying to create a vanity url that points to the following url:
https://{rest-api-id}-{vpce-id}.execute-api.{region}.amazonaws.com/{stage} -
I am attempting to accomplish this task by creating a CNAME from
sub.mydomain.comto{rest-api-id}-{vpce-id}.execute-api.{region}.amazonaws.com. -
However, even though I can hit the amazonaws.com url directly (calling without host headers and seeing the correct results), when using my url, I am getting a
403 forbidden. -
Surprisingly, attaching the
Host: {api-gateway-id}.execute-api.{region}.amazonaws.commakes my url work, but the purpose ofhttps://{rest-api-id}-{vpce-id}.execute-api.{region}.amazonaws.com/{stage}is to make the call without needing the host header. -
Edit: Another surprise, attaching the
Host: https://{rest-api-id}-{vpce-id}.execute-api.{region}.amazonaws.com/{stage}(The Route53 Alias for API Gateway associated with VPC) also makes my url work. This support is not currently listed in AWS documentation. -
Edit: Current suspicion is that calling sub.mydomain.com/{stage}, is automatically attaching the
Host: sub.mydomain.com, which AWS VPC doesn't know how to currently handle and route to the corresponding private api gateway. AWS may need to find a way to allow users to create "API Gateway ID Host Aliases', so that user's can benefit from that simplified Route53 alias (or another approach needs to be looked at).
Any help would be appreciated. Thanks!
Relevant Links:
-
https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-private-api-test-invoke-url.html (Accessing Your Private API Using a Route53 Alias)
-
https://aws.amazon.com/about-aws/whats-new/2019/09/amazon-api-gateway-simplifies-invoking-private-apis/ (Amazon API Gateway Simplifies Invoking Private APIs)
Posted Mar 13, 2020, 2:27 PM UTC · edited
You’re trying to use a custom domain for Private APIs. This is not currently supported
https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-custom-domains.html
I added more details to the OP, as my team looked into it further.
The "API Gateway associated with VPCE, Route53 Alias" feature was released at the end of 2019, which I think user's on my end were expecting to remove this blocker. However, it may not be currently supported as you have said.
I am hoping to reach out to AWS support next week to confirm your's and my thoughts.
Thank you for the comment u/badoopbadoopbadoop !