英文:
Configure firebase functions to use a service account for deploying
问题
以下是您要翻译的内容:
在查看云函数文档时,它显示了一种使用服务账号部署函数的选项,而不是让它在默认服务账号下运行:
gcloud functions deploy <function> --service-account <service_account_email>
在运行 firebase deploy
时,Firebase 是否有一种配置以使用服务账号部署函数的方法?
我尝试了直接将其添加到 .firebaserc
文件的简单方法,但我不知道是否支持或正确的语法是什么:
{
"projects": {
"default": "<project>"
},
"targets": {
"<project>": {
"functions": {
"service-account": "<...>@<project>.iam.gserviceaccount.com"
}
}
}
}
英文:
When looking at the docs for cloud functions it shows an option to deploy the function using a service account instead of having it run with the default service account:
gcloud functions deploy <function> --service-account <service_account_email>
Is there is a way in firebase to configure it to deploy a function using a service account when running firebase deploy
?
I've tried doing a straight-forward dumb approach of adding it to the .firebaserc
file, but I don't know if that is supported or what the correct syntax would be:
{
"projects": {
"default": "<project>"
},
"targets": {
"<project>": {
"functions": {
"service-account": "<...>@<project>.iam.gserviceaccount.com"
},
}
}
答案1
得分: 1
你可以使用RunTime options interface更改Firebase函数部署的服务帐户。例如:
import * as functions from "firebase-functions";
export const myfunc = functions.runWith({serviceAccount:"sa@goog.com"}).https.onCall(async (request, context) => {
}
当您在不添加任何额外参数的情况下使用Firebase CLI 时,该函数应该使用指定的服务帐户进行部署。
firebase deploy --only functions:myfunc
如果操作正确,您将看到函数详细信息部分的服务帐户已更改为指定的服务帐户。
英文:
You can change the service account the firebase function is deployed with using the RunTime options interface. For example:
import * as functions from "firebase-functions";
export const myfunc = functions.runWith({serviceAccount:"sa@goog.com"}).https.onCall(async (request, context) => {
}
When you use the firebase cli without any additional parameters, the function should be deployed with the specified service account.
firebase deploy --only functions:myfunc
If done correctly, you will see that the Service Account in the details section of the function is changed to the specified service account.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论