我正在尝试将现有的 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
工作,但导入失败。