Skip to content

Private Hosted Zone (cloudmap) can i create a record to route to a specific api end point

0

I ahve a hosted Zone named (private namespace) "yellowcar.local" that resolves with in my private vpc, i want to create a record in the the namespace "api.yellowcar.local" that resolves to a rest apigateway (v1) with in my private vpc so that i can call https://api.yellowcar.local/v1/wheelDetails I have vpce to allow invoke/execution of the api. My questions is how do i set up the a services in cloudmap namespaces so that i can do this.

2 Answers
0

To set up a record in your private hosted zone "yellowcar.local" that resolves to your private REST API Gateway, you'll need to create an A record that points to your VPC endpoint. Here's how to do it:

  1. In the Route 53 console, navigate to your private hosted zone "yellowcar.local"
  2. Choose "Create record"
  3. If presented with "Quick create" method, switch to the wizard method
  4. Choose "Simple Routing" for the routing policy and click "Next"
  5. In the "Configure records" page, choose "Define simple record"
  6. For "Record name", enter "api" (this will create api.yellowcar.local)
  7. For "Record type", keep the value as "A - Routes traffic to an IPv4 address and some AWS resources"
  8. For "Value/Route traffic to", choose "Alias to VPC endpoint"
  9. Select your Region and then choose the VPC endpoint that you created for your API Gateway
  10. Choose "Define simple record" to create your record

Once this is set up, requests to https://api.yellowcar.local/v1/wheelDetails will be routed to your private API Gateway through the VPC endpoint. Make sure your security groups and network configurations allow traffic between your resources and the API Gateway.

If you're using IPv6 for your VPC endpoint, you would create an AAAA record type instead. If using dualstack for your VPC endpoint, you should create both A and AAAA record types.
Sources
Using AWS IoT Core with interface VPC endpoints - AWS IoT Core
Create VPC interface endpoint and private hosted zone - AWS IoT Wireless
Tutorial: Create and invoke a custom domain name for private APIs - Amazon API Gateway

answered 16 days ago
0

Yes, you can route api.yellowcar.local to your Private API Gateway endpoint, but Cloud Map alone won’t work directly for this use case due to how API Gateway endpoints and DNS resolution work.

Best Approach that I can think of: Use a Route 53 Private Hosted Zone for yellowcar.local and create a CNAME record like this: Record Name: api.yellowcar.local
Type: CNAME
Value: vpce-xyz.execute-api.us-east-1.vpce.amazonaws.com
TTL: 60 Make sure this hosted zone is associated with the same VPC where your API Gateway VPC endpoint (VPCE) exists.

Why not Cloud Map? Cloud Map works great for IP-based targets (like ECS or EC2), but not ideal for routing to API Gateway VPC endpoints. It doesn't support CNAME records in private namespaces, so you can't register the endpoint DNS name directly through it.

Things to Check: Your API Gateway must be set up as Private. The VPC endpoint must allow execute-api. Test from within the VPC using: curl https://api.yellowcar.local/v1/wheelDetails

This setup should let you use your internal domain (api.yellowcar.local) to access the Private API.

answered 16 days ago
  • Hi, I'm unsure as to how this works when i have 2 apigateways .. the above set up does not specify a particaular api apgateway. hows does the system know how to route it

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.