【问题标题】:Terraform google bucket for static website for google storage - 403用于谷歌存储的静态网站的 Terraform 谷歌存储桶 - 403
【发布时间】:2020-04-02 02:09:56
【问题描述】:

尝试为静态网站创建一个谷歌存储桶。

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"
  }
}

> terraform 应用

googleapi:错误 403:您尝试创建的存储桶是域名 由其他用户拥有。,禁止

为 AWS 找到了这个 answer

问:是否可以从 Terraform for Google Cloud 创建以存储域为中心的存储/存储桶?

【问题讨论】:

  • 有可能,但错误是存储桶名称解析为已被其他用户使用的名称。
  • 但是另一个用户是我。在此之前我已经移除了水桶。等了10分钟左右。也许必须等待 24 小时.. 不确定。
  • Terraform 能否创建 GCS 存储桶。是的,参考是terraform.io/docs/providers/google/r/storage_bucket.html

标签: google-cloud-platform terraform


【解决方案1】:

(假设您已经拥有verified the domainmywebsite.com,并且您是该域的所有者)

我可以看到您正在使用服务的帐户凭据创建存储桶:

提供者“谷歌”{

project = "myprojectname-123"

凭据 = "${file("storage-admin.json")}"

region = "us-central1"

zone = "us-central1-c"

}

您必须将该服务帐户添加为域的所有者,因为创建这些资源的 terraform API 调用将使用其凭据来创建存储桶。

如果该帐户不在域的所有者列表中,您将收到 403 以及您收到的消息。 Documentation on how to add the service account as an owner.

此外,请确保将服务帐户添加为域所有者,而不是网站所有者。

【讨论】:

    猜你喜欢
    • 2020-07-02
    • 2020-02-27
    • 1970-01-01
    • 2018-12-24
    • 1970-01-01
    • 2021-11-15
    • 2020-06-01
    • 2020-12-31
    • 2016-01-31
    相关资源
    最近更新 更多