terraform init 和 terraform plan 成功运行后,terraform apply 报告 S3 后端配置错误

2024-02-02

我正在我的 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成功地。


看来您已经添加了新的 s3 作为后端。 所以 terraform 需要重新初始化。 赶紧跑terraform init,它将添加 s3 作为后端,并请求将本地状态文件传输到 s3 的权限。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

terraform init 和 terraform plan 成功运行后,terraform apply 报告 S3 后端配置错误 的相关文章

随机推荐