Terraform Octopus Integration - Remote Backend Configuration

Hi there!

I am trying to integrate Terraform with Octopus and have a couple of issues. Mentioning the most important one below:

  1. I have a basic Terraform template which I am able to deploy using “Apply Terraform Step”. The template is inline for now.
  2. I just added this remote backend:

terraform {
backend “s3” {
bucket = “bucketname”
key = “bucket_name/some_key”
region = “ap-southeast-2”
}
}

  1. Deployed again and got the below message in Octopus:
    “terraform.exe” init -no-color -get-plugins=true

Info
Initializing the backend…
July 17th 2019 15:41:55
Info
Successfully configured the backend “s3”! Terraform will automatically
July 17th 2019 15:41:55
Info
use this backend unless the backend configuration changes.
July 17th 2019 15:41:55
Error
Error refreshing state: Terraform 0.11.8 does not support state version 4, please update.
July 17th 2019 15:41:55
Error
Calamari.Integration.Processes.CommandLineException: The following command: “terraform.exe” init no-color -get-plugins=true
July 17th 2019 15:41:55
Error
With the working directory of: D:\Octopus\Work\20190717061149-13638-156
July 17th 2019 15:41:55
Error
Failed with exit code: 1
July 17th 2019 15:41:55
Error
Error refreshing state: Terraform 0.11.8 does not support state version 4, please update.

  1. I now logged on to Octopus Server, placed Terraform v0.12.4 on it and added to $PATH with a hope that OD will probably use the latest version of Terraform however, again the same error message mentioned above.
  2. My questions are:
  • How do we find what version of Terraform will be used by Octopus?
  • And how to force it to use the latest version to get past this error message?

For those who run into the same issue:
Make sure you are using a new bucket or a bucket with no existing Terraform state otherwise, there would be a conflict.
This helped me solving the problem.

Hi Andy,
We are happy to hear you solved this issue and for providing the solution.

Happy Deployments!

Best Regards,
Tina