尝试为静态网站创建一个谷歌存储桶。
provider "google" {
project = "myprojectname-123"
credentials = "${file("storage-admin.json")}"
region = "us-central1"
zone = "us-central1-c"
}
resource "google_storage_bucket" "STANDARD" {
name = "mywebsite.com"
storage_class = "STANDARD"
location = "US"
website {
main_page_suffix = "index.html"
not_found_page = "404.html"
}
}
> 地形应用
googleapi:错误 403:您尝试创建的存储桶是域名
由另一个用户拥有。,禁止
找到了这个answer https://stackoverflow.com/questions/47831151/terraform-backend-s3-bucket-creation-returns-403-w-terraform-0-11-1 for AWS
问:是否可以从 Terraform for Google Cloud 创建以存储域为中心的存储/存储桶?
(假设你已经已验证域名 https://cloud.google.com/storage/docs/domain-name-verification#verification mywebsite.com,并且您是该域的所有者)
我可以看到您正在使用服务的帐户凭据创建存储桶:
提供商“谷歌”{
项目 =“myprojectname-123”
凭证 =“${file("storage-admin.json")}"
区域 =“us-central1”
区域 =“us-central1-c”
}
您必须将该服务帐户添加为域的所有者,因为创建这些资源的 terraform API 调用将使用其凭据来创建存储桶。
如果该帐户不在域的所有者列表中,您将收到 403 以及您收到的消息。有关如何将服务帐户添加为所有者的文档 https://cloud.google.com/storage/docs/domain-name-verification#additional_verified_owners.
另外,请确保将服务帐户添加为域所有者,而不是网站所有者。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)