首页 > 解决方案 > 为 terraform 设置 gcs 后端的问题

问题描述

我一直在尝试设置一个 terraform 后端来将状态文件存储在 GCS 存储桶中。我创建了一个服务帐户,它是项目所有者并具有 gcs 存储桶存储管理员访问权限,但仍然面临以下错误:

Initializing the backend...
Error loading state: 2 errors occurred:
        * writing "gs://terraform-ubuntu-state-maintain/gcp/terraform.tfstate/default.tflock" failed: googleapi: Error 403: Insufficient Permission, insufficientPer
missions
        * storage: object doesn't exist. 

ps:gcs 存储桶也已经创建,前缀路径为“gcp”。还授予服务帐户权限。

标签: google-cloud-platformgoogle-cloud-storageterraformterraform-provider-gcp

解决方案


我的错误是“配额项目”~/.config/gcloud/application_default_credentials.json指向一个不存在的项目。


推荐阅读