首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >terraform在terraform init & terraform计划成功运行后用S3报告后端配置错误

terraform在terraform init & terraform计划成功运行后用S3报告后端配置错误
EN

Stack Overflow用户
提问于 2018-06-12 14:24:40
回答 3查看 7.5K关注 0票数 4

我正在我的Linux实例上运行terraform,下面是可怕的部分。

代码语言:javascript
复制
+ /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配置文件。

代码语言:javascript
复制
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应用程序之前,我成功地运行了terraform plan

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2018-06-12 17:57:25

似乎您已经添加了新的s3作为后端。所以地形需要重新初始化。只需运行terraform init,它将添加s3作为后端,并请求将本地状态文件传输到s3的权限。

票数 8
EN

Stack Overflow用户

发布于 2018-07-17 09:55:33

您需要先初始化provider,然后用最新版本下载提供者,输出如下:-

代码语言:javascript
复制
# terraform init

Initializing provider plugins...
- Checking for available provider plugins on https://releases.hashicorp.com...
- Downloading plugin for provider "spotinst" (1.1.1)...

The following providers do not have any version constraints in configuration,
so the latest version was installed.

To prevent automatic upgrades to new major versions that may contain breaking
changes, it is recommended to add version = "..." constraints to the
corresponding provider blocks in configuration, with the constraint strings
suggested below.

* provider.aws: version = "~> 1.2"
* provider.cloudflare: version = "~> 0.1"
* provider.spotinst: version = "~> 1.1"

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.`
票数 0
EN

Stack Overflow用户

发布于 2018-11-01 17:58:57

我将首先删除任何状态文件和.terraform文件夹,许多错误有时由于损坏而存在。

然后我会跑进去,然后它就会跑。

我不认为添加后端是问题所在,因为它应该试图在各州之间合并。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50819556

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档