google-cloud-platform - Terraform - GCP - 连接:连接被拒绝
问题描述
上周,一切正常。但是今天当我再次运行 terraform apply 时,我的所有资源都出现以下错误:
错误:发布“https://storage.googleapis.com/storage/v1/b?alt=json&prettyPrint=false&project=PROJECTID”:拨打 tcp SOMEIPTHATCANTSHARE:443:连接:连接被拒绝
我必须:
创建 BigQuery 数据集和表。
创建存储桶
我尝试“gcloud auth login”和“gcloud auth application-default login”
我必须以下消息:
UserWarning: Your application has authenticated using end user credentials from Google Cloud SDK without a quota project. You might receive a "quota exceeded" or "API not enabled" error. We recommend you rerun \gcloud auth application-default login` and make sure a quota project is added. Or you can use service accounts instead. For more information about service accounts, see[https://cloud.google.com/docs/authentication/](https://cloud.google.com/docs/authentication/).. warnings.warn(_CLOUD_SDK_CREDENTIALS_WARNING)`
Cannot add the project "A PROJECT FROM ANOTHER GOOGLE CLOUD ACCOUNT" to ADC as the quota project because the account in ADC does not have the "serviceusage.services.use" permission on this project. You might receive a "quota_exceeded" or "API not enabled" error. Run $ gcloud auth application-default set-quota-project to add a quota project.```
解决方案
除非您非常熟悉 Google 应用程序默认凭据和配额,否则该错误确实没有帮助。
Google 不鼓励将最终用户凭据(在本例中为您使用的gcloud auth list
凭据)用作应用程序默认凭据。当然,该设施存在,但只能谨慎使用。
我不清楚所有原因,但一个重要的原因application_default_credentials.json
是创建的文件具有与您的最终用户帐户匹配的权限并且是不记名令牌;任何其他获得它的人都可以像您一样行事(r 帐户)。
每当您以这种方式运行软件时,强烈建议您创建一个具有必要权限的服务帐户。
您的问题不清楚您是更喜欢使用Cloud Console还是 Cloud SDK(又名gcloud
)。
您将需要:
- BigQuery 创建数据集|表(也许
roles/bigquery.dataEditor
?); - Cloud Storage 创建存储分区(也许
roles/storage.admin
?)
- 可选的*
- 为服务帐号创建密钥
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json
- 再次运行 terraform 脚本
可选* - 如果您从例如 Compute Engine 运行脚本,则无需创建密钥,因为您可以使用 VM 自己的服务帐户。请参阅作为服务帐户进行身份验证
推荐阅读
- python - 在 Django 中编写我自己的自定义后端
- javascript - 带有内联函数参数的Angularjs工厂
- python - 改进对 Raspberry Pi RC 机器人的控制
- python - 使用Python通过javascript onclick下载文件?
- sql-server - 如果没有数据,如何使报告的一部分可见
- python - 为什么我的 print() 命令在控制台中显示双打?
- python - python子进程空输出和错误
- python - 不理解 `if` 语句中的特定代码
- c++ - 如何在 C++ 中处理 -nan 输出
- javascript - WEB API - 如何使用身份为用户中的自定义属性添加值