DEV Community

Cover image for Associating a Custom Domain to an API Gateway on Google Cloud
Rodrigo Burgos
Rodrigo Burgos

Posted on

4

Associating a Custom Domain to an API Gateway on Google Cloud

Setting up a custom domain for your API Gateway on Google Cloud enhances the professional appearance of your APIs and improves brand consistency. Here's a step-by-step guide to achieve this.

Prerequisites

Ensure you have:

  • A domain name managed via Google Cloud DNS or any other DNS provider.
  • An SSL certificate configured in Google Cloud.
  • Steps to Configure API Gateway with a Custom Domain

Steps to Configure API Gateway with a Custom Domain

1 - Create Serverless NEG for API Gateway

gcloud beta compute network-endpoint-groups create api-gateway-serverless-neg --region=us-central1 --network-endpoint-type=serverless --serverless-deployment-platform=apigateway.googleapis.com --serverless-deployment-resource=gateway-name
Enter fullscreen mode Exit fullscreen mode

2 - Attach NEG to Backend Service

gcloud compute backend-services add-backend api-gateway-backend-service --global --network-endpoint-group=api-gateway-serverless-neg --network-endpoint-group-region=us-central1
Enter fullscreen mode Exit fullscreen mode

3 - Create URL Map

gcloud compute target-https-proxies create api-gateway-https-proxy --ssl-certificates=dfb-dev-ssl-cert --url-map=api-gateway-url-map
Enter fullscreen mode Exit fullscreen mode

4 - Create HTTPS Proxy

gcloud compute target-https-proxies create api-gateway-https-proxy --ssl-certificates=dfb-dev-ssl-cert --url-map=api-gateway-url-map
Enter fullscreen mode Exit fullscreen mode

5 - Create Forwarding Rule

gcloud compute forwarding-rules create my-fw --target-https-proxy=api-gateway-https-proxy --global --ports=443
Enter fullscreen mode Exit fullscreen mode

Testing

Verify the custom domain points to the API Gateway:

curl -v https://your-custom-domain.com
Enter fullscreen mode Exit fullscreen mode

Conclusion
By following these steps, you can seamlessly associate a custom domain with your API Gateway, ensuring secure and branded API endpoints.

For more detailed documentation, refer to Google Cloud API Gateway Custom Domains.

Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Google’s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more