我正在尝试让 Lambda 在公共子网内运行以与互联网进行通信。我可以让 Lambda 在没有 VPC 的情况下访问 www.google.com(文档称其在幕后运行),但如果我在 VPC 中运行 Lambda,则无法访问。
重现步骤:
我尝试过对此方法的修改,但没有取得任何成功(例如,实际上将子网与 vpc 关联,放松安全组和网络 ACL 上的所有设置)。
我最初尝试遵循一个公共文档和一个私人文档,但未能成功。
有任何想法吗?谢谢!- 丹
const http = require('http');
exports.handler = async (event) => {
return httprequest().then((data) => {
const response = {
statusCode: 200,
body: JSON.stringify(data),
};
return response;
});
};
function …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用不同的服务帐户部署 Google Cloud Functions。我将服务帐户属性保存到 json 文件中。我交换了值以使其更易于阅读。
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/keys/mynewserviceaccount.json"
gcloud functions deploy MyFunction \
--runtime python37 \
--entry-point MyFunction \
--source src \
--service-account mynewserviceaccount@appspot.gserviceaccount.com \
--verbosity debug \
--stage-bucket staging.projectname.appspot.com \
--trigger-event providers/cloud.firestore/eventTypes/document.write \
--trigger-resource "projects/projectname/databases/(default)/documents/User/{userId}" &
Run Code Online (Sandbox Code Playgroud)
mynewserviceaccount 具有以下角色。我已经尝试了其他一些,但都没有成功。- 云函数管理员 - 云函数服务代理 - 错误编写器 - 服务帐户用户 - 日志编写器 - 发布/订阅订阅者
我还运行了 gcloud auth activate-service-account mynewserviceaccount@appspot.gserviceaccount.com --key-file "/path/to/keys/mynewserviceaccount.json"
当我运行这个时,我得到:错误:(gcloud.functions.deploy) ResponseError: status=[403], code=[Forbidden], message=[调用者没有权限]
当我尝试在角色列表中查找“gcloud.functions.deploy”时,我没有看到它。我不知道这是文档问题还是代码问题。