【问题标题】:Terraform backend remote config with Google Cloud Buckets使用 Google Cloud Buckets 进行 Terraform 后端远程配置
【发布时间】:2017-10-04 14:06:27
【问题描述】:

我正在运行以下命令并看到 Terraform has been successfully initialized! 的输出

terraform init \
  -backend=true \
  -backend-config="bucket=terraform-remote-states" \
  -backend-config="project=<<my-poject>>" \
  -backend-config="path=terraform.tfstate"

但是,当我运行模板时,它会在本地而不是在 GCS 中创建状态文件。

不确定我在这里缺少什么。感谢任何想法和帮助。

【问题讨论】:

标签: google-cloud-platform google-cloud-storage terraform


【解决方案1】:

当您执行列出的terraform init 命令时,您似乎在该目录中的任何.tf 文件中都没有如下所示的backend 块。

terraform {  
  backend "gcs" {
    bucket  = "terraform-state"
    path    = "/terraform.tfstate"
    project = "my-project"
  }
}

您传递的那些 -backend-config 参数都不会告诉 Terraform 您希望状态进入 GCS。

如果没有上述明确的 backend "gcs" {} 声明,Terraform 将默认在本地存储状态,这是您当前看到的行为。

【讨论】:

    猜你喜欢
    • 2018-03-11
    • 2020-06-12
    • 2019-11-11
    • 2020-05-17
    • 2022-12-22
    • 2019-11-03
    • 1970-01-01
    • 2018-11-21
    相关资源
    最近更新 更多