How to deploy terraform tf files through octopus

How to deploy multiple terraform tf files through octopus

Hey there @kakarlayogitha - can you tell me a little more about your Terraform? Are you deploying separate environments, or separate projects? Are they all within the same package, or are you specifying them inline using the built in Terraform steps?

Learning a little more about how you’re using the steps today and you’re ultimate goal with multiple files will help me provide relevant recommendations and help!

Hello ,

Currently we want to deploy our couple of tf files ( , , output , etc) through octopus as part of single project.

Kindly help me on how to do the same

i need to deploy aws resources / create aws resources through octopus


In our current project , we have couple of terraform files as attached zip file

kindly let us know where to mention var file information

we have uploaded tis zip file as package and we are using it in “.Apply a Terraform template” step

Kindly guide (1.1 KB)

Hey @kakarlayogitha , thanks for sharing that additional context and sample file!

There are some great resources on working with Terraform in our documentation - that said, here are some resources around your specific use case.

With your current file structure, the Octopus configuration for deploying with your variable files is similar to using it from the command line.

If you were using this terraform from the command line, you’d use a command like terraform apply --var-file="", because is the file that contains all of your variable defaults.

Using the Apply a Terraform Template step, this option is available under Advanced Options → Terraform Options → Custom terraform apply parameters. The example above would look like this:

Something else to mention is that Octopus offers native variable substitution for Terraform files - following the examples in the documentation, you could create Octopus variables that map to your Terraform and allow you to not need the .var files in the first place.

Hopefully this helps get you unblocked, feel free to reach out if you have any additional questions or run into any issues!


PFA screenshots which shows the process .please suggest me for error.we have uploaded the zip package of terraform files (as attached previously) as Package and am using it here .

PFA screeshots

When i tried to create release with above process , i get below error attached in txt file ServerTasks-1889.log.txt (18.0 KB)

Sorry @kakarlayogitha , my initial screenshot was incorrect - the input you’re looking for is under Template → Package → Additional Variable files:

An optional newline-separated list of files that are passed as -var-file parameters. Note that files called terraform.tfvars , terraform.tfvars.json ,*.auto.tfvars and *.auto.tfvars.json are automatically loaded by Terraform, and do not need to be listed here. Each line in this text area is passed as an individual -var-file parameter.

So, instead of -var-file="", you should be able to just put the file name in that box and have it handled by the Octopus step. Sorry for the misinformation on that part!

1 Like

we are getting error again.PFA ServerTasks-2033.log.txt (11.5 KB)

Please suggest us

Your task logs indicate an issue with running terraform init against the main file.

Can you confirm that you can correctly terraform init and terraform apply from your local CLI?

It looks like there may be issues with your Terraform syntax - I noticed you have the file we’ve been discussing, as well as a terraform.tfvars and a file. According to the terraform documentation, your input files for variables should end in .tfvars. You have your variables declared in, but you’re missing some values in your two .tfvars file. Your file also references Terraform resources that don’t exist in your module - and

Please recheck your source code and ensure it’s working correctly, that will help isolate where the issues are occurring in Octopus.


I am trying to use this terraform package
PFA and let us know (802 Bytes)

we need to have this terraform available in worker node right ?

i have ran below commands on worker node …Please check and suggest me

C:\Users\Administrator>terraform init
Terraform initialized in an empty directory!

The directory has no Terraform configuration files. You may begin working
with Terraform immediately by creating Terraform configuration files.

C:\Users\Administrator>terraform apply

│ Error: No configuration files

│ Apply requires configuration to be present. Applying without a configuration would mark everything for destruction,
│ which is normally not what is desired. If you would like to destroy everything, run ‘terraform destroy’ instead.

@kakarlayogitha - Correct, you’ll need Terraform installed on your worker. However, you’ll need to run the commands in the directory of your .tf files, rather than in the home directory. In this case, you’d want to run it in your terraform-ec2.0.2 folder.

I looked at your updated code, and I think you may still have some issues with variable declarations and variable assignment. I’d recommend taking another look at the Hashicorp documentation on variables and making sure your code matches the expected input variable behavior: Input Variables - Configuration Language - Terraform by HashiCorp


However, you’ll need to run the commands in the directory of your .tf files, rather than in the home directory. In this case, you’d want to run it in your terraform-ec2.0.2 folder.---- How can we ensure this ?? as mentioned earlier screenshots , i have given parameter as var.tfvars in additional variable files step

but still release failed with error .PFA file
ServerTasks-2059.log.txt (17.6 KB)

ServerTasks-2257.log.txt (21.4 KB)

I have sorted out few issues and we are getting below issue now

Please suggest us (985 Bytes)


Kindly find our latest code and errors while release.

Please suggest us how to deploy terraform through octopus (1.1 KB)
ServerTasks-2347.log.txt (21.6 KB)

Hi @kakarlayogitha,

Just stepping in for Cory.

From the logs you’ve provided, it seems that Terraform is looking for ‘var.tfvars’ as the variable file however the files you’ve provided has the name ‘variable.tfvars’ instead.

05:40:57 Info | "terraform.exe" apply -no-color -auto-approve -var-file=""
Screen Shot 2021-11-29 at 12.01.27

Feel free to let me know if this doesn’t help resolve the issue or if you get any further error messages!

Best Regards,

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.