Deploy an API to a gateway

This page describes how to deploy an API to API Gateway.

Prerequisites

Before you can deploy an API to API Gateway, ensure that you do the following:

Gateway ID requirements

Many of the gcloud CLI commands shown below require you to specify the ID of the gateway, in the form: GATEWAY_ID. API Gateway enforces the following requirements for the gateway ID:

  • Must have a maximum length of 49 characters.
  • Must contain only lowercase letters, numbers, or dashes.
  • Must not start with a dash.
  • Must not contain an underscore.

Define the endpoint of the deployed API config

When you deploy an API config to a gateway, API Gateway creates a unique URL for the gateway in the gateway.dev domain. Your API clients then use a URL in the form below to access the deployed API config:

https://GATEWAY_ID-HASH.REGION_CODE.gateway.dev

where GATEWAY_ID is the name of the gateway, HASH is the unique hash code generated when you deployed the API, and REGION_CODE is the code for the Cloud location in which you deployed the gateway.

For example:

https://my-gateway-a12bcd345e67f89g0h.uc.gateway.dev

Deploy an API to a gateway

To deploy an API to a gateway:

Google Cloud console

  1. In the Google Cloud console, go to the API Gateway page.

    Go to API Gateway

  2. Click Create Gateway

    The Create Gateway page displays.

  3. In the Select an API, select Create new API in the Select an API field.
  4. In the Display Name field, enter the display name of the API.
  5. In the API ID field, enter the ID of the API. See API ID requirements for API naming guidelines.
  6. (Optional) Add labels for your API.
  7. In the API Config section, select Create a new API config in the Select a Config field
  8. In the Upload an API Spec field, upload a .yaml or .json file. See OpenAPI 2.0 and OpenAPI 3.x file formats for API definition.
  9. In the Display Name field, enter the display name of the API config.
  10. In the Select a Service Account list, select the required service account. This service account will be used by API Gateway as its identity.
  11. (Optional) Add labels for your API config.
  12. In the Gateway details section, enter a display name for your gateway.
  13. In the Location field, select the Google Cloud region where you want to deploy your gateway.
  14. (Optional) Add labels for your API Gateway.
  15. Click Create gateway.
  16. The newly created API is visible on the API Gateway homepage.

Google Cloud CLI

  1. Validate the project ID returned from the following command to make sure that the gateway isn't created in the wrong project.

    gcloud config list project

    If you need to change the default project, run the following command and replace