TLDR;我在为服务帐号分配 IAM 权限时遇到问题。
我正在构建一个测试,涉及使用 firebase Auth 生成自定义令牌。当我打:
const token = await admin.auth().createCustomToken('test', {
isAdmin: true,
})
Run Code Online (Sandbox Code Playgroud)
抛出以下错误
Permission iam.serviceAccounts.signBlob is required to perform
this operation on service account
projects/-/serviceAccounts/dashboard@appspot.gserviceaccount.com.;
Please refer to
https://firebase.google.com/docs/auth/admin/create-custom-tokens
for more details on how to use and troubleshoot this feature
Run Code Online (Sandbox Code Playgroud)
在引用的文档中,它说将服务帐户令牌创建者角色添加到服务帐户。我已经添加了该角色(以及尝试服务帐户管理员无济于事。

我可以验证我的权限似乎设置正确,当我运行时,
gcloud projects get-iam-policy project我可以看到我的服务帐户附加到所需的角色
- members:
- serviceAccount:dashboard@appspot.gserviceaccount.com
role: roles/iam.serviceAccountTokenCreator
Run Code Online (Sandbox Code Playgroud)
但是,如果我查看该特定服务帐户,它似乎显示为空,这与我的错误一致:
gcloud iam service-accounts get-iam-policy dashboard@appspot.gserviceaccount.com
etag: ACAB
Run Code Online (Sandbox Code Playgroud)
我认为导致我的服务帐户权限显示为空白的原因是罪魁祸首,但我不确定在哪里进一步调试。在我看来,唯一的区别是一个命令被调用,其中包含一个项目,但我使用项目 ID 初始化了我的 firebase 应用程序,并已对其进行了验证,(firebase-admin).apps[0].options因此这似乎是一个死胡同。
google-cloud-platform firebase-authentication google-iam google-cloud-iam
网上有很多例子展示了如何在部署在 GCP/GCE 上的虚拟机上使用 Terraform 运行启动脚本,但它们都使用内联启动脚本,所有启动脚本代码都包含在 terraform compute.tf 文件中。这可以通过启动脚本的单行或多行的 <<SCRIPT[script code]SCRIPT 来完成。我还没有找到一个示例来展示如何将启动脚本参数分配给本地磁盘上的另一个文件,可能与 compute.tf 位于同一目录中。用数百行启动脚本将compute.tf 弄得一团糟。没有更好的方法来做到这一点吗?
我意识到我可以编写一个包装脚本,将一个 compute.tf 和一个单独的启动文件组合到一个 compute.tf 中,然后运行 terraform,但我正在寻找一条更直接的路线,假设存在。
谢谢你。
我一直在使用以下 Java 方法在 GCS 中设置存储桶通知。
private void setBucketNotification(String bucketName, String topicId) {
List<String> eventType = new ArrayList<>();
eventType.add("OBJECT_FINALIZE");
try {
Notification notification = new Notification();
notification.setTopic(topicId);
notification.setEventTypes(eventType);
notification.setPayloadFormat("JSON_API_V1");
final GoogleCredential googleCredential = GoogleCredential
.fromStream(Objects.requireNonNull(classloader.getResourceAsStream("Key.json")))
.createScoped(Collections.singletonList(StorageScopes.DEVSTORAGE_FULL_CONTROL));
final com.google.api.services.storage.Storage myStorage = new com.google.api.services.storage.Storage.Builder(
new NetHttpTransport(), new JacksonFactory(), googleCredential).build();
Notification v = myStorage.notifications().insert(bucketName, notification).execute();
} catch (IOException e) {
log.error("Caught an IOException {}",e);
}
}
Run Code Online (Sandbox Code Playgroud)
到目前为止,它一直运行良好,但最近,我收到了关于GoogleCredential课程弃用的投诉,并尝试进行一些研究,希望找到可能的替代品,但找不到任何东西。谁能帮我指出正确的方向?
我正在使用 typescript、express 和Sequelize.
这是我的database连接类。
export class Database {
private _sequelize: Sequelize;
private config: DBConfigGroup = dbConfig;
private env = process.env.NODE_ENV as string;
constructor() {
this._sequelize = new Sequelize({
dialect: 'postgres',
database: this.config[this.env].database,
username: this.config[this.env].username,
password: this.config[this.env].password,
host: this.config[this.env].host,
});
}
async connect(): Promise<void> {
try {
console.log('start connect');
await this._sequelize.authenticate();
console.log('Connection has been established successfully.'.green.bold);
} catch (error) {
console.error('Unable to connect to the database:'.red.bold, error);
}
}
async close(): Promise<void> {
try {
await this._sequelize.close(); …Run Code Online (Sandbox Code Playgroud) node.js sequelize.js google-cloud-sql google-cloud-platform docker-compose
遇到构建部署功能的问题。尝试以编程方式部署该函数时,我在构建器日志(错误)中得到以下输出。
2020-10-20T02:22:12.155866856Z starting build "1fc13f51-28b6-4052-9a79-d5d0bef9ed5c"
I
2020-10-20T02:22:12.156015831Z FETCHSOURCE I
2020-10-20T02:22:12.156031384Z Fetching storage object: gs://gcf-sources-629360234120-us-central1/${FUNCTIONNAME}-63f501f1-a8d2-4837-b992-1173ced83036/version-1/function-source.zip#1603160527600655 I
2020-10-20T02:22:16.698838385Z Copying gs://gcf-sources-629360234120-us-central1/${FUNCTIONNAME}-63f501f1-a8d2-4837-b992-1173ced83036/version-1/function-source.zip#1603160527600655... I
2020-10-20T02:22:16.848908949Z / [0 files][ 0.0 B/ 7.6 KiB]
/ [1 files][ 7.6 KiB/ 7.6 KiB]
I
2020-10-20T02:22:16.848965618Z Operation completed over 1 objects/7.6 KiB. I
2020-10-20T02:22:17.848654342Z replace /workspace/pb/__init__.py? [y]es, [n]o, [A]ll, [N]one, [r]ename: NULL I
2020-10-20T02:22:17.848694354Z (EOF or read error, treating as "[N]one" ...) I
2020-10-20T02:22:17.848697209Z Archive: /tmp/source-archive.zip I
2020-10-20T02:22:17.848698273Z inflating: /workspace/main.py I
2020-10-20T02:22:17.848699274Z creating: /workspace/pb/ I
2020-10-20T02:22:17.848700378Z inflating: /workspace/pb/__init__.py I
2020-10-20T02:22:17.848701376Z …Run Code Online (Sandbox Code Playgroud) deployment google-cloud-platform google-cloud-functions google-cloud-iam google-cloud-build
google_project文档说project_id是可选的。
\n\n\nproject_id - (可选)项目 ID。如果未提供,则使用提供者项目。
\n
然而,Terraform 抱怨这是必需的。
\ngcp.tf
\ndata "google_project" "project" {\n}\n\noutput "project_number" {\n value = data.google_project.project.number\n}\nRun Code Online (Sandbox Code Playgroud)\n Error: project: required field is not set\n\xe2\x94\x82 \n\xe2\x94\x82 with data.google_project.project,\n\xe2\x94\x82 on gcp.tf line 1, in data "google_project" "project":\n\xe2\x94\x82 1: data "google_project" "project" {\nRun Code Online (Sandbox Code Playgroud)\n请帮助理解这是否是文档缺陷并且该参数实际上是强制性的。
\n设置 GOOGLE_PROJECT 环境变量。
\nexport GOOGLE_PROJECT=...\nterraform apply\nRun Code Online (Sandbox Code Playgroud)\n 将 docker 容器映像部署到 Cloud Run 时,我可以选择一个区域,这很好。Cloud Run 将构建委托给 Cloud Build,它显然创建了两个存储桶来实现这一点。意外的行为是存储分区不是在 Cloud Run 部署的区域中创建的,而是默认为美国多区域。
如何将区域指定为“us-east1”,以便“始终免费”层承担存储成本? (显然,美国多区域存储桶将数据存储在免费层限制之外的区域,这导致了意外账单 - 我试图避免该账单。)
如果重要的话,我也在这个项目中使用 Firebase。我在 us-east1 区域创建了 Firebase 默认存储桶,希望它也能成为其他桶的默认存储桶,但事实并非如此。最终的存储桶列表如下所示,您可以在其中看到使用不需要的多区域设置自动创建的两个存储桶。
这是我用来构建和部署的 shell 脚本:
#!/bin/sh
project_id=$1
service_id=$2
if [ -z "$project_id" ]; then
echo "First argument must be the Google Cloud project ID" >&2
exit 1
fi
if [ -z "$service_id" ]; then
echo "Second argument must be the Cloud Run app name" >&2
exit 1
fi
echo "Deploying $service_id to $project_id"
tag="gcr.io/$project_id/$service_id"
gcloud builds submit \
--project …Run Code Online (Sandbox Code Playgroud) google-cloud-storage google-cloud-platform google-cloud-build google-cloud-run
问题:如何删除应用程序徽标。
解决方案:此答案中的先前解决方案/sf/answers/4001760591/不再有效。
Google 将 的格式更改"iconUrl"为"icon",现在使用 -Base64编码的数据流,例如"icon":"iVBORw0KGgoAAAAN...,而不是以前写为 的图像 URL "iconUrl":"https://..."。
我试过"icon":""许多Base64编码的值一样"icon":"IA","icon":"Lw"和一些其他-没有成功。我收到控制台消息,例如
为了 "icon":""
{
"error": {
"code": 400,
"message": "The request failed because one of the field of the resource is invalid.",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.rpc.PreconditionFailure",
"violations": [
{
"type": "client_auth_config",
"subject": "?error_code=9&error_field_name=UpdateIconRequest.icon&error_field_value=%3CByteString@3eeee81e+size%3D0+contents%3D%22%22%3E"
}
]
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
或者
{
"error": {
"code": 400,
"message": "Request contains an …Run Code Online (Sandbox Code Playgroud) google-api google-apps-script google-oauth google-cloud-platform google-workspace
我想在 Mac OS 上通过 pip 安装来安装 google-cloud-pubsub,但出现错误:distutils.errors.CompileError: command '/usr/bin/clang' failed with exit code 1. 我运行的命令:pip install google-cloud-pubsub==2.1.0。
这里是完整的错误信息。
有什么建议吗?谢谢!
更多信息:
$ python -V
Python 3.9.0
$ pip -V
pip 20.2.4 from /.../lib/python3.9/site-packages/pip (python 3.9)
$ sw_vers
ProductName: macOS
ProductVersion: 11.0.1
BuildVersion: 20B29
Run Code Online (Sandbox Code Playgroud)
我见过其他类似的案例,但它们并没有解决我的问题。我试过:
macos pip python-3.x google-cloud-platform google-cloud-pubsub
我正在尝试将 Docker 映像拉入 Google Cloud Run。我看到我可能需要先将它拉到 Google Container Registry,但我能以某种方式避免它吗?另外,我宁愿直接从源头获得它以使其保持最新状态。
docker google-cloud-platform google-container-registry google-cloud-run
terraform ×2
deployment ×1
docker ×1
google-api ×1
google-iam ×1
google-oauth ×1
java ×1
macos ×1
node.js ×1
pip ×1
python-3.x ×1
sequelize.js ×1
startup ×1