首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法在区域[terraform]中创建google云存储桶

无法在区域[terraform]中创建google云存储桶
EN

Stack Overflow用户
提问于 2017-08-20 11:52:13
回答 2查看 4K关注 0票数 2

我正在尝试使用区域us-west1-a中的terraform创建一个gcs桶,storage-class作为REGIONAL。但是当我这样做的时候,我会得到这个错误

代码语言:javascript
复制
* google_storage_bucket.terraform-state: 1 error(s) occurred:

* google_storage_bucket.terraform-state: googleapi: Error 400: The combination of locationConstraint and storageClass you provided is not supported for your project, invalid

这是我现在拥有的.tf文件

代码语言:javascript
复制
resource "google_storage_bucket" "terraform-state" {
  name          = "terraform-state"
  storage_class = "${var.storage-class}"
}

provider "google" {
  credentials = "${file("${path.module}/../credentials/account.json")}"
  project     = "${var.project-name}"
  region      = "${var.region}"
}

variable "region" {
  default = "us-west1" # Oregon
}

variable "project-name" {
  default = "my-project"
}

variable "location" {
  default = "US"
}

variable "storage-class" {
  default = "REGIONAL"
}

文档

EN

回答 2

Stack Overflow用户

发布于 2017-08-21 22:46:21

CreateBucket请求中指定的位置是区域,而不是区域(参见https://cloud.google.com/compute/docs/regions-zones/regions-zones中的定义)。“我们-西部-a”是一个区域。请尝试使用“request 1”(这是包含美国西部1-a区域)的请求。

票数 5
EN

Stack Overflow用户

发布于 2017-08-27 00:15:45

看起来您实际上还没有在资源中指定一个位置,所以它默认为"us“,这是无效的,因为它不是一个区域。尝试:

代码语言:javascript
复制
resource "google_storage_bucket" "terraform-state" {
  name          = "terraform-state"
  storage_class = "${var.storage-class}"
  location      = "${var.location}"
}

variable "location" {
  default = "us-west1"
}

variable "storage-class" {
  default = "REGIONAL"
}

注意,我已经将" location“添加到资源中,并将location变量设置为实际所需的GCS位置。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45781840

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档