Terraform google bucket for static website for google storage - 403

﹥>﹥吖頭↗ 提交于 2021-02-19 05:23:07

问题


Trying to create a google bucket for the static website.

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 apply

googleapi: Error 403: The bucket you tried to create is a domain name owned by another user., forbidden

Found this answer for AWS

Q: Is it possible to create storage domain centric storage/bucket from Terraform for Google Cloud?


回答1:


(Assuming that you have already verified the domain mywebsite.com, and that you are an owner of the domain)

I can see that you are creating the bucket using a service's account credentials:

provider "google" {

project = "myprojectname-123"

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

region = "us-central1"

zone = "us-central1-c"

}

You will have to add that service account as an owner of the domain, since the terraform API Call to create those resources will use its credentials to create the bucket.

If the account is not on the owner list of the domain, you will receive the 403, with the message that you are getting. Documentation on how to add the service account as an owner.

As well, make sure that you add the service account as a domain owner, not a site owner.



来源:https://stackoverflow.com/questions/59240978/terraform-google-bucket-for-static-website-for-google-storage-403

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!