我在我的地形库中有一个单一的地形文件:
# main.tf
terraform {
backend "remote" {
hostname = "app.terraform.io"
}
}
和一个配置文件
# backend_config.hcl
workspaces { name = "my-workspace" }
organization = "my-favourite-organisation"
我想为本地规划初始化我的repo,但我无法访问实际状态文件:
$ terraform init -backend-config=backend_config.hcl
Initializing the backend...
╷
│ Error: Required token could not be found
│
│ Run the following command to generate a token for app.terraform.io:
│ terraform login
╵
所以我初始化没有后端:
$ terraform init -backend=false
Initializing provider plugins...
Terraform has been successfully initialized!
但是现在当我尝试和计划时,Terraform抱怨后端需要初始化:
$ terraform plan
╷
│ Error: Backend initialization required, please run "terraform init"
│
│ Reason: Initial configuration of the requested backend "remote"
在不访问远程状态文件的情况下如何进行本地计划?
在本地系统初始化后端。$ terraform init
$ terraform plan