Reputation: 47
When i am doing terraform init commands, TF is not having the tfstate ( my tfstate file is in s3 bucket ). Also i am not able to see the terraform backend-config file inside the .terraform folder.
I am using terraform 0.10.4 version
Outputs:
$ 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/
In present location TF will take the backup of the s3-tfstate file, but it's not there.
Upvotes: 2
Views: 8681
Reputation: 45243
This is expect behaviour after 0.9.x. The local tfstate file at .terraform/terraform.tfstate
is almost an empty file. The only change is the serial number in it. It keeps increasing.
"serial": 1,
If you don't run terraform apply
, the remote tfstate file will not be updated. If you never run terraform apply
, the remote tfstate file does not exist.
So try to make some changes, then check the remote tfstate file (in your case, it is s3://$TF_STATE_BUCKET/$TF_STATE_KEY
), you should see the difference.
Upvotes: 2