【发布时间】:2020-03-19 06:24:17
【问题描述】:
输入
例如,我们有一些服务。
- 账户服务
- 产品服务
- 支付服务
每个服务都是一个单独的 Google Cloud Function。 每个服务都有自己的 HTTP API。例如,账户服务有:
- https://REGION-FUNCTIONS_PROJECT_ID.cloudfunctions.net/account/sign-up
- https://REGION-FUNCTIONS_PROJECT_ID.cloudfunctions.net/account/sign-in
- https://REGION-FUNCTIONS_PROJECT_ID.cloudfunctions.net/account/reset-password
- 等
每个服务都有自己的 swagger 文档端点 /docs。
问题
如何将我的 Cloud Functions 设为私有(没有公共访问权限)并将它们放在某个 API 网关后面?
注意事项
Google 为 Cloud Functions 提供端点(请参阅https://cloud.google.com/endpoints/docs/openapi/get-started-cloud-functions)。 但是,据我了解,Endpoints 只允许您定义 yaml OpenAPI 文件。
在这个 yaml 文件中,我可以定义如下内容:
swagger: '2.0'
info:
title: Cloud Endpoints + GCF
description: Sample API on Cloud Endpoints with a Google Cloud Functions backend
version: 1.0.0
host: HOST
schemes:
- https
produces:
- application/json
paths:
/hello:
get:
summary: Greet a user
operationId: hello
x-google-backend:
address: https://REGION-FUNCTIONS_PROJECT_ID.cloudfunctions.net/helloGET
responses:
'200':
description: A successful response
schema:
type: string
但就我而言,我需要能够代理我的云功能(如反向代理)。
【问题讨论】:
标签: google-cloud-platform architecture google-cloud-functions microservices api-gateway