GCP API Gateway with multiple gRPC backend services

Viewed 18

I have two (backend) gRPC cloud run services and I would like to expose both of them in a singe API Gateway. I have successfully exposed one of the two services through a gateway by following the tutorial at https://cloud.google.com/api-gateway/docs/get-started-cloud-run-grpc. However, I cannot find an example with multiple backend services. I have tried modifying the api_config.yaml file from the tutorial as follows:

apis:
  - name: FirstService
  - name: SecondService
backend:                                  
  rules:
    - selector: 'FirstService.*'
      address: 'grpcs://first-cloud-run-service-url'
    - selector: 'SecondService.*'
      address: 'grpcs://second-cloud-run-service-url'

The two services are described by two separate .proto files (which, ideally, I don't want to modify). I generate two separate descriptor .pb files from them and pass them both to --grpc-files argument of gcloud api-gateway api-configs create. (--grpc-files=first_descriptor.pb,second_descriptor.pb,api_config.yaml)

With this I get the following errors:

message: "Cannot resolve api \'FirstService\'."
message: "backend rule has selector(s) \'FirstService.*\' that do not match and are not shadowed by other rules."

It seems that the second .pb file somehow replaces the first. (When I comment out all lines related to the first service in api_config.yaml it works.)

0 Answers
Related