Built-in terraform steps do not work

When attempting to use Terraform Plan or Terraform Apply built-in steps, I receive the following error message:

16:46:09 Info | “terraform.exe” --version
16:46:09 Info | Terraform v0.11.8
16:46:09 Info | Your version of Terraform is out of date! The latest version
16:46:09 Info | is 0.12.24. You can update by downloading from www.terraform.io/downloads.html
16:46:09 Info | “terraform.exe” init -no-color -get-plugins=true
16:46:09 Info | Initializing the backend…
16:46:09 Info | Successfully configured the backend “azurerm”! Terraform will automatically
16:46:09 Info | use this backend unless the backend configuration changes.
16:46:11 Info | Terraform has been successfully initialized!
16:46:11 Info | “terraform.exe” workspace list
16:46:11 Error | Calamari.exe : e[31mUsage: terraform workspace list [DIR]
16:46:11 Error | At C:\Octopus\Work\20200408234608-127-2\Bootstrap.ps1:43 char:1
16:46:11 Error | + & "C:\Octopus\OctopusServer\Tools\Calamari.Cloud\11.1.2\Calamari.exe …
16:46:11 Error | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16:46:11 Error | + CategoryInfo : NotSpecified: (e[31mUsage: ter…pace list [DIR]:String) [], RemoteException
16:46:11 Error | + FullyQualifiedErrorId : NativeCommandError
16:46:11 Error | List Terraform workspaces.e[0me[0m
16:46:11 Error | Calamari.Integration.Processes.CommandLineException: The following command: “terraform.exe” workspace list
16:46:11 Error | With the working directory of: C:\Octopus\Work\20200408234608-127-2
16:46:11 Error | Failed with exit code: 1
16:46:11 Error | e[31mUsage: terraform workspace list [DIR]
16:46:11 Error | List
16:46:11 Error | Terraform workspaces.e[0me[0m
16:46:11 Error | at Calamari.Integration.Processes.CommandResult.VerifySuccess()
16:46:11 Error | at Calamari.Terraform.TerraformCLIExecutor.InitializeWorkspace()
16:46:11 Error | at Calamari.Terraform.PlanTerraformConvention.Execute(RunningDeployment deploymen
16:46:11 Error | t, Dictionary2 environmentVariables) 16:46:11 Error | at Calamari.Terraform.TerraformConvention.<InstallAsync>d__4.MoveNext() 16:46:11 Error | --- End of stack trace from previous location where exception was thrown --- 16:46:11 Error | at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Th 16:46:11 Error | row() 16:46:11 Error | at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 16:46:11 Error | at Calamari.Terraform.TerraformConvention.Install(RunningDeployment deployment) 16:46:11 Error | at Calamari.Deployment.ConventionProcessor.RunInstallConvent 16:46:11 Error | ions() 16:46:11 Error | at Calamari.Deployment.ConventionProcessor.RunConventions() 16:46:11 Error | Running rollback conventions... 16:46:11 Error | The following command: "terraform.exe" workspace list 16:46:11 Error | With the working directory of: C:\Octopus\Work\20200408234608-127-2 16:46:11 Error | Failed with exit code: 1 16:46:11 Error | e[31mUsage: terraform workspace list [DIR] 16:46:11 Error | List Terraform workspaces.e[0me[0m 16:46:11 Error | Calamari.Integrati 16:46:11 Error | on.Processes.CommandLineException 16:46:11 Error | at Calamari.Integration.Processes.CommandResult.VerifySuccess() 16:46:11 Error | at Calamari.Terraform.TerraformCLIExecutor.InitializeWorkspace() 16:46:11 Error | at Calamari.Terraform.PlanTerraformConvention.Execute(RunningDeployment deploymen 16:46:11 Error | t, Dictionary2 environmentVariables)
16:46:11 Error | at Calamari.Terraform.TerraformConvention.d__4.MoveNext()
16:46:11 Error | — End of stack trace from previous location where exception was thrown —
16:46:11 Error | at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Th
16:46:11 Error | row()
16:46:11 Error | at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
16:46:11 Error | at Calamari.Terraform.TerraformConvention.Install(RunningDeployment deployment)
16:46:11 Error | at Calamari.Deployment.ConventionProcessor.RunInstallConvent
16:46:11 Error | ions()
16:46:11 Error | at Calamari.Deployment.ConventionProcessor.RunConventions()
16:46:11 Error | at Calamari.Terraform.TerraformCommand.Execute(String[] commandLineArguments)
16:46:11 Error | at Calamari.Program.Run(CommonOptions options)
16:46:11 Error | at Calamari.Program.Main(String[] args)
16:46:11 Verbose | Process C:\Windows\system32\WindowsPowershell\v1.0\PowerShell.exe in C:\Octopus\Work\20200408234608-127-2 exited with code 100
16:46:11 Verbose | Updating manifest with output variables
16:46:11 Verbose | Updating manifest with action evaluated variables
16:46:11 Fatal | The remote script failed with exit code 100
16:46:11 Fatal | The action Plan TF on the Octopus Server failed

This may have something to do with having variables in the TF configuration.

I was finally able to get this working by using a .tf definition file in a package and using the Octopus variable replacement syntax in the main .tf file.

Using the inline script with variables was not working at all. Also, any command line arguments passed to terraform do not work at all including inline and package deployment methods.

1 Like