我想在我的 Cloud Run 托管 API 前面使用 API 网关,并且只允许从 API 网关访问 Cloud Run URL。
我目前有一个 API 部署到 Cloud Run,并启用了“公共”入口和授权。这有效,但是我很好奇是否可以将 Cloud Run 上的入口模型更改为“内部”,以完全避免将任何互联网流量路由到我的 Cloud Run 容器。
我知道 API Gateway 处于 Beta 版,内部入口的某些方面似乎也是 Beta 版——但是我很好奇是否有办法使这项工作发挥作用。
根据入口文档,似乎如果我能以某种方式使我的 API 网关请求来自 VPC 网络,则此设置应该可以工作,但是我无法找到在 API 网关端实现此目的的方法。
google-cloud-platform google-cloud-run google-vpc google-cloud-api-gateway
我最近切换到谷歌云功能第 2 代,并且在通过 API 网关进行身份验证时遇到问题。我的网关正在调用新的云功能,该功能本身不允许未经授权的用户。网关附加了一个服务帐户,该帐户具有云函数调用者角色(以及所有者角色,因为我正在进行故障排除)。
云函数日志中的错误信息为
该请求未经过身份验证。允许未经身份验证的调用或设置正确的授权标头。如需了解更多信息,请访问https://cloud.google.com/run/docs/securing/authenticating其他故障排除文档可在以下位置找到:https: //cloud.google.com/run/docs/troubleshooting#unauthorized-client
我有一个测试函数,其代码相同,使用云函数第 1 代,并且不允许未经身份验证的用户。当您访问我的 api 网关时,此功能非常有用。我还有一个第二代云功能,它允许未经身份验证的用户,并且在访问网关时也按预期工作,只是我的第二代不允许未经身份验证的用户。
对于我的 API 网关 yaml 文件,该文件如下所示(敏感信息 XXX 已删除),
swagger: "2.0"
info:
title: XXXXXXXX api gateway for carson blade analytics app
description: Sample API on API Gateway with a Google Cloud Functions backend
version: 1.0.0
schemes:
- https
produces:
- application/json
paths:
/convert_csv:
get:
summary: Converts an XLSX file to a CSV file
operationId: convert
x-google-backend:
address: https://convert-csv-XXXXX-ue.a.run.app
responses:
"200":
description: A successful response
schema: …Run Code Online (Sandbox Code Playgroud) google-cloud-platform google-cloud-functions google-cloud-api-gateway
我已使用 GCP API Gateway 设置了一个 api,将 api 调用映射到多个 Cloud Run 服务,但现在我需要将自定义域指向 API 网关。我发现没有像 Cloud Run 中那样的选项,我还尝试设置指向网关网址的 CNAME 记录,但没有成功。
他们无论如何我可以设置网关的域名吗?
我在 Cloud Run 后端前面有一个 Google Cloud Api 网关。如果两者都是公开的,一切正常。
如果我在 Cloud Run 上选中“仅允许内部流量”,Api Gateway 无权访问后端。有没有办法在 Api Gateway 和 Cloud Run 之间保持私有连接?
另一个问题。有没有办法使用私有 IP 在我的网络中拥有 Api 网关?
google-cloud-platform google-cloud-run google-cloud-api-gateway
我已经在 GCP 中设置了一个 API 网关,现在我正在尝试在网关前面配置 GCP 的负载平衡。为了做到这一点,我所做的是:
设置完成后,我尝试从前端 IP 地址访问负载均衡器,但收到 404
我是否错过了服务配置中的任何步骤?
cloudflare google-cloud-platform gcp-load-balancer google-cloud-api-gateway
我正在使用具有 firebase JWT 授权的 API 网关(以便用户可以使用 google 登录),该网关将请求转发到云运行服务和一项云功能服务。
\n我的 API 网关配置如下:
\nswagger: \'2.0\'\ninfo:\n version: \'1.0.0\'\n title: \'BFF\'\n description: Backend For Frontend\nschemes:\n - https\nsecurity:\n - firebase: []\nsecurityDefinitions: \n firebase:\n authorizationUrl: ""\n flow: "implicit"\n type: "oauth2"\n x-google-issuer: "https://securetoken.google.com/${PROJECT}"\n x-google-jwks_uri: "https://www.googleapis.com/service_accounts/v1/metadata/x509/securetoken@system.gserviceaccount.com"\n x-google-audiences: ${PROJECT}\npaths:\n /test/auth:\n post:\n operationId: testAuth\n summary: Test auth\n produces:\n - application/json\n x-google-backend:\n address: https://${REGION}-${PROJECT}.cloudfunctions.net/auth-test\n responses:\n \'200\':\n description: \'Response returns user related data from JWT\'\n /record/new:\n post:\n operationId: crateRecord\n summary: Create new record\n x-google-backend:\n address: ${RUN_SERVICE_URL}:${RUN_SERVICE_PORT}/new\n produces:\n - application/json\n parameters:\n …Run Code Online (Sandbox Code Playgroud) google-cloud-platform google-cloud-functions google-cloud-run google-cloud-api-gateway google-cloud-auth
我想知道将 Google BigQuery 表查询结果存储到 Google Cloud 存储的最佳方式是什么。我的代码目前正在一些 Jupyter Notebook 中运行(在 Vertex AI Workbench 中,与 BigQuery 数据源以及 Cloud Storage 目标相同的项目),如下所示:
# CELL 1 OF 2
from google.cloud import bigquery
bqclient = bigquery.Client()
# The query string can vary:
query_string = """
SELECT *
FROM `my_project-name.my_db.my_table`
LIMIT 2000000
"""
dataframe = (
bqclient.query(query_string)
.result()
.to_dataframe(
create_bqstorage_client=True,
)
)
print("Dataframe shape: ", dataframe.shape)
# CELL 2 OF 2:
import pandas as pd
dataframe.to_csv('gs://my_bucket/test_file.csv', index=False)
Run Code Online (Sandbox Code Playgroud)
此代码大约需要 7.5 分钟才能成功完成。
是否有更优化的方法来实现上面所做的事情?(这意味着更快,但也许其他方面还可以改进)。
一些附加说明:
google-cloud-storage google-bigquery google-cloud-platform google-cloud-api-gateway google-cloud-vertex-ai