After you have configured Endpoints in an OpenAPI document, you deploy it so that Cloud Endpoints has the information that it needs to manage your API. This page describes how to deploy an OpenAPI document to Cloud Endpoints using the gcloud endpoints services deploy command.
As a starting point, this page assumes that you have:
- Created a Google Cloud Platform (GCP) project in which you have the Editor or Owner role. See Controlling API Access of Project Members for more information.
- Configured Endpoints.
If you are using a custom domain name (for example,
must verify the domain name
before you can deploy the OpenAPI document.
gcloud for deployment
You use the
gcloud command line tool from the Cloud SDK to deploy the
To prepare for the deployment:
Install and initialize the Cloud SDK.
Update the Cloud SDK and install the Endpoints components:
gcloud components update
Make sure that Cloud SDK is authorized to access your data and services on GCP:
gcloud auth login
Use Application Default Credentials:
gcloud auth application-default login
Set the default project to your GCP project ID.
gcloud config set project [YOUR-PROJECT-ID]
Deploying the OpenAPI document
When you deploy your API, the
gcloud command-line tool uses the
Google Service Management API to upload your API
configuration to create a managed service. After a successful deployment, you
can view the API in the
To deploy your OpenAPI document:
For simplicity, this page refers to the OpenAPI document as
Change directory to the location containing your API's
Invoke the following command:
gcloud endpoints services deploy openapi.yaml
The first time that you deploy
openapi.yaml, Service Management
creates a new Cloud Endpoints service with a name that matches
the text that you specified in the
host field in the
openapi.yaml file, and
then configures the service according to your OpenAPI document.
As it is creating and configuring the service, Service Management outputs a great deal of information to the terminal. On successful completion, you see a line like the following that displays the service configuration ID and the service name:
Service Configuration [2017-02-13-r0] uploaded for service [echo-api.endpoints.example-project.cloud.goog]
In the above example,
2017-02-13-r0 is the service configuration
echo-api.endpoints.example-project.cloud.goog is the
Whenever you change something in your OpenAPI document, be sure to deploy it again so that Cloud Endpoints has the most recent version of your API's configuration.