执行terraform apply时遇Google Provider OAuth2令牌获取超时错误求助
Terraform 部署GCP存储桶时出现OAuth2令牌获取超时错误
我被这个问题卡了两天:按照课程指引创建了项目服务账号,给它分配了BigQuery Admin、Compute Admin等必要权限,把密钥放在main.tf同级的keys子文件夹里,并且在provider块配置了credentials = "./keys/my-creds.json"。但执行terraform apply时出现以下超时错误:
google_storage_bucket.demo-bucket: Creating... google_storage_bucket.demo-bucket: Still creating... [10s elapsed] google_storage_bucket.demo-bucket: Still creating... [20s elapsed] google_storage_bucket.demo-bucket: Still creating... [30s elapsed] ╷ │ Error: Post "https://storage.googleapis.com/storage/v1/b?alt=json&prettyPrint=false&project=coherent-ascent-379901": oauth2: cannot fetch token: Post "https://oauth2.googleapis.com/token": dial tcp 172.217.163.42:443: i/o timeout
我的main.tf内容如下:
terraform { required_providers { google = { source = "hashicorp/google" version = "5.13.0" } } } provider "google" { credentials = "./keys/my-creds.json" # Credentials only needs to be set if you do not have the GOOGLE_APPLICATION_CREDENTIALS set project = "coherent-ascent-379901" region = "us-central1" } resource "google_storage_bucket" "demo-bucket" { name = "coherent-ascent-379901-terra-bucket" location = "US" force_destroy = true lifecycle_rule { condition { age = 2 //days } action { type = "AbortIncompleteMultipartUpload" } } }
我已经尝试了以下操作,但错误依然存在:
- 用
gcloud auth list确认服务账号和用户账号均处于活跃状态 - 执行
gcloud components update将SDK更新至最新版本 - 通过
gcloud auth application-default print-access-token成功获取到访问令牌 - 执行
gcloud auth application-default login重新完成授权
有没有人遇到过类似的问题?
内容的提问来源于Stack Exchange,提问作者Lili Li
相关产品推荐
相关产品推荐

