Aymen Gasmi
Aymen Gasmi

Reputation: 474

Terraform version error when deploying to AWS through jenkins?

I was deploying using terraform through Jenkins Terraform v0.10.7. After a success deployment from my local machine using Terraform v0.11.1, I can not do it again from Jenkins, I have this error :

Terraform doesn't allow running any operations against a state
that was written by a future Terraform version. The state is
reporting it is written by Terraform '0.11.1'.

Upvotes: 4

Views: 6104

Answers (3)

A colleague of mine, Manuel Sierra has bumped into this error and concluded with the following solution: (Be careful with the following, it is going to give version errors if you happen to downgrade to another version incompatible with the code)

In our case, downgrade from 0.11.14 to 0.11.13 yielded no errors.

  1. Execute terraform state pull > current.state
  2. Modify the version with the one executed by you
  3. Execute terraform state push current.state

Now you are good to go with the downgraded version.

Upvotes: 0

barakbd
barakbd

Reputation: 1102

If you are using TFE maybe you can re-queue the previous state created with 0.11.x. Or perhaps you can look in Jenkins history to get the last state created with 0.11.x.

Upvotes: 0

forzagreen
forzagreen

Reputation: 2683

  • Using v0.11.1 run: $ terraform destroy
  • Remove the .tfstate file
  • Using v0.10.7 (or any version you want to use from now on), run: $ terraform apply

Upvotes: 6

Related Questions