我在我的Linux实例上运行terraform,我得到了下面的恐怖 .
+ /usr/local/bin/terraform workspace new test
enter code here[0m[0m[1m[33mBackend reinitialization required. Please run "terraform init".[0m
[33mReason: Initial configuration of the requested backend "s3"
The "backend" is the interface that Terraform uses to store state,
perform operations, etc. If this message is showing up, it means that the
Terraform configuration you're using is using a custom configuration for
the Terraform backend.
Changes to backend configurations require reinitialization. This allows
Terraform to setup the new configuration, copy existing state, etc. This is
only done during "terraform init". Please run that command now then try again.
If the change reason above is incorrect, please verify your configuration
hasn't changed and try again. At this point, no changes to your existing
configuration or state have been made.
[0m
[31mFailed to load backend: Initialization required. Please see the error message above.
这是Terraform配置文件 .
provider "aws" {
# don't touch below here
access_key = "${var.aws_access_key}"
secret_key = "${var.aws_secret_key}"
region = "us-west-2"
}
# Configure Terraform to store this in S3
terraform {
backend "s3" {
bucket = "nom-terraform"
key = "apps/onboarding/terraform.tfstate"
region = "us-west-2"
}
}
在运行terraform apply之前,我成功运行了 terraform plan
.
3 回答
似乎你已经添加了新的s3作为后端 . 因此,terraform需要重新初始化 . 只需运行
terraform init
,它将添加s3作为后端并请求权限将本地状态文件传输到s3 .您需要首先初始化提供,下载具有最新版本的提供程序,输出将是这样的: -
我会首先删除任何状态文件和.terraform文件夹,有时由于损坏而存在许多错误 .
之后我会运行init,它应该运行 .
我不相信添加后端是问题,因为它应该尝试在各州之间合并