google-cloud-platformgoogle-compute-enginegoogle-vpcgoogle-api-gateway

GCP API Gateway for Compute Engine


I found the following snippet on api gateway marketing page. enter image description here

So I was setting up API gateway for my app running on compute engine. As I couldn't find any documentation on how to configure compute engine on API engine, I created the following configuration with the internal DNS.enter link description here

swagger: "2.0"
info:
  title: API Endpoints
  description: API Endpoints
  version: 1.0.1
schemes:
  - https
produces:
  - application/json
paths:
  /indexes:
    get:
      summary: Return Search Indexes
      operationId: searchIndexes
      x-google-backend:
        address: http://my_internal_dns_for_compute_engine.c.myproject.internal/indexes
        path_translation: APPEND_PATH_TO_ADDRESS
      responses:
        "200":
          description: A successful response
          schema:
            type: string
        "403":
          description: Failed to authenticate

When I deployed the config using gcloud, I got the following error

Waiting for API Config [my-api-config-v6] to be created for API [my-api]...failed.
ERROR: (gcloud.beta.api-gateway.api-configs.create) Wait for Service Config creation: Backend URL "http://my_internal_dns_for_compute_engine.c.myproject.internal/indexes" is forbidden: cannot route requests to an internal address.

So looks like internal DNS is not supported(obviously).

My compute engine instance can only be accessed through a VPC network. How do I connect my api gateway with the VPC network and how do I access my compute engine through it ?


Solution

  • Today, you can't achieve this. Your API gateway is a serverless service and you can't plug a serverless VPC connector on it. I already discussed this with Google (because it's the same problem with Cloud Scheduler, Cloud Task and PubSub push subscription for example) and something should happen soon. Stay tuned!!

    Anyway, to solve now your issue, you have 2 solutions (at least, one sure and one to test)


    EDIT 1

    I have tested the second solution and it works with the internal IP (and with a serverless VPC connector on the Cloud Run Endpoint service with ESPv2 deployed), not with the internal DNS name.