当我执行terraform init命令时,TF没有tfstate (我的tfstate文件在s3存储桶中)。此外,我无法在.terraform文件夹中看到terraform backend-config文件。
我使用的是terraform 0.10.4版本
输出:
$ terraform --version
Terraform v0.10.4
$ terraform init \
-lock="true"
-backend-config="bucket=$TF_STATE_BUCKET"
-backend-config="key=$TF_STATE_KEY"
-backend-config="dynamodb_table=$TF_LOCK_TABLE"
-backend-config="region=$AWS_REGION"
-backend-config="profile=$AWS_PROFILE"
-backend-config="encrypt=true"
.
Downloading modules...
Get: git::ssh://XXXXXXXXXXXXXXXXX/add/tf-vpc.git?ref=1.0.1
Get: git::ssh://XXXXXXXXXXXXXXXXX/add/tf-ec-redis.git?ref=1.1.3
Get: git::ssh://XXXXXXXXXXXXXXXXX/add/tf-rds-pg.git?ref=1.3.0
Initializing provider plugins...
Checking for available provider plugins on https://releases.hashicorp.com...
Downloading plugin for provider "aws" (0.1.4)...
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 = "~> 0.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.
$ ll -al .terraform/
total 8
drwxr-xr-x 1 XXXXX 1049089 0 Sep 12 18:10 modules/
drwxr-xr-x 1 XXXXX 1049089 0 Sep 12 18:10 plugins/在当前位置,TF将备份s3-tfstate文件,但它不在那里。
发布于 2017-09-13 18:20:22
这是0.9.x之后的预期行为。.terraform/terraform.tfstate上的本地tfstate文件几乎是一个空文件。唯一的变化是其中的序列号。它一直在增加。
"serial": 1,如果不运行terraform apply,则不会更新远程tfstate文件。如果您从未运行过terraform apply,那么远程tfstate文件就不存在。
因此,尝试进行一些更改,然后检查远程tfstate文件(在您的示例中,它是s3://$TF_STATE_BUCKET/$TF_STATE_KEY),您应该会看到区别。
https://stackoverflow.com/questions/46194464
复制相似问题