terraform云远程后端

时间:2019-09-29 16:04:38

标签: terraform terraform-provider-github terraform-cloud

我正在尝试将现有的github存储库导入terraform。我决定尝试使用Terraform Cloud,并进行设置后,即使一切设置正确,terraform import也会因401 unauthorized而失败。

基本上,我有这个:

provider "github" {
  token        = "${var.github_token}"
  organization = "goreleaser"
}

terraform {
  required_version = "~> 0.12.0"
}

variable "github_token" {
  type = string
}

resource "github_repository" "goreleaser" {
  name = "goreleaser"
}

如果我运行terraform import github_repository.goreleaser goreleaser,它会按预期运行(我的环境中有TF_VAR_github_token)。

如果我添加远程后端:

terraform {
  required_version = "~> 0.12.0"

  backend "remote" {
    hostname     = "app.terraform.io"
    organization = "goreleaser"

    workspaces {
      name = "tf"
    }
  }
}

运行相同的命令,我得到:

github_repository.goreleaser: Importing from ID "goreleaser"...
github_repository.goreleaser: Import prepared!
  Prepared github_repository for import
github_repository.goreleaser: Refreshing state... [id=goreleaser]

Error: GET https://api.github.com/repos/goreleaser/goreleaser: 401 Bad credentials []

这可以吗?

我也在terraform云上设置了变量-远程terraform plan可以工作,但是导入失败。

0 个答案:

没有答案