I am not familiar with GCP, however very familiar with AWS. The project in question had a requirement to be on GCP, so I need a little help.
Use case is simple, I need several domains (ie. domain1.com, domain2.com, *.domain3.com) to all point to and route ALL PATH REQUESTS to the same back end service, which is a cloud function.
As part of that flow, I need the original domain, and the path, passed to that cloud function (in the header or parameters) as I will be looking up information in firebase/firestore based on the domain and path, followed by performing an action.
I believe I have the first part setup correctly, but I am now stumped.
What I have done.
- Cloud function created, using node/express for reading the route and providing a response.
- api/gateway/config setup, with this config:
swagger: "2.0"
info:
title: test api
description: test api
version: 1.0.0
schemes:
- https
produces:
- application/json
paths:
/:
get:
summary: root request
operationId: rootRequest
x-google-backend:
address: https://us-central1-project-name.cloudfunctions.net/cloudFunctionName
responses:
"200":
description: A successful response
schema:
type: string
/{code}:
get:
summary: path request
operationId: pathRequest
parameters:
- name: code
in: path
description: actual code to look up
required: true
type: string
x-google-backend:
address: https://us-central1-project-name.cloudfunctions.net/cloudFunctionName
path_translation: APPEND_PATH_TO_ADDRESS
responses:
"200":
description: A successful response
schema:
type: string
- Setup NEG for the API GATEWAY (ie gateway.dev domain)
- THIS IS WHERE I AM STUMPED. I'm setting up the load balancer, routing to a new backend service configured to the NEG in step 3. When at the frontend IP/port, I set to https, and the certificate requires domains, however, I am not able to add *.domain3.com because of the wildcard. This is hard requirement. Not sure where to go from here.
Questions:
- Is this setup directionally correct for achieving what I described at the top??
I need several domains (ie. domain1.com, domain2.com, *.domain3.com) to all point to and route ALL PATH REQUESTS to the same back-end service, which is a cloud function."
- Is there another way to allow a wildcard domain to the load balancer. I thought of perhaps setting up a Cloud CDN (not enabling CDN on the load balancer, but actually creating a unique CDN) and routing the origin to the load balancer, but haven't had a chance to test that.