Currently attempting to setup Octopus/NuGet integration using a ProGet server, as my package host. However I am at a loss in regards to how I need to configure the variable replacement for a ‘list’. When the replacement piece within Octopus attempts to replace the information with the Octopus variable within the resource, it does not remove the double quotes surrounding the variable.
As such it errors in relation to configuration and the object within the Terraform resource needing to be a list. Please reference the below screenshots and GitHub repository for more information.
FYI, this is a trial 30 day license so that I can vet out this solution and offer it as an option to individuals at my work place. Please reach out to me with additional questions/requirements, I’m most likely just doing this wrong.
Just checking, are you expecting to pass this variable in from Octopus? I would recommend using a tfvars files for your variable values - one with local test values, and one that has octopus variable replacements in it, that you can refer to from Octopus.
Thanks for getting back to me, so I currently am using Teamcity to do a terraform validation/ init/lint on the code after replacing ‘#{’ with ‘${var.’ which then verifies if the code is good or not at that level. From there I repull and create a package for octopus to use. Thank you for all our help!
To make sure I understand fully… If you wrap it in quotes, it works in teamcity with the init, but not in Octopus, but if you remove the quotes, it no longer works in teamcity?
I highly suspect you’ll have more luck with using .tfvars files to set the variables, and use the same template in both places.
Unfortunately I am at a loss in regards to what you mean. For variable substitution to work from a Terraform file to octopus the variable ‘must’ be in #{variable} format matching an octopus variable. However if you have this within a file and attempt to run Terraform native on the file with the octopus variable, it is my understanding that it will fail due to syntax issues.
*PS … I just realized I could paste/attach images… so sorry for external linking to stuff.
Can you please provide a reference code subset for this scenario so that I can understand in more depth?
Step Template Replace Variables:
Matt has gone on holidays, I’ll try to help you out.
I think Matt is suggesting the use of tfvar file for each environment where Terraform will be executed. Have an Octopus variable file that will contain the Octopus substitution syntax, and another file that has whatever syntax is required where it will run. You can apply the files individually: https://learn.hashicorp.com/terraform/getting-started/variables.html#from-a-file.
Unfortunately I don’t believe this will work, as I need to validate /lint that the code is good via terraform before doing Octopus substitutions. I find it limiting that Octopus cannot manage ‘list’ objects for terraform correctly. Do you know if this is something that can be requested/voted on and if so, where do I submit this?
Thank you,
EDIT: I was able to get this to work, by modifying the file with teamcity, prior to packing/uploading the nuget file for octopus. This however is very hackish, and believe this is as stated a limitation in the octopus variable replacement. For a production environment, this is not sustainable/trusted as it is modifying the code after the validation step… please provide a link or way for me to submit a request for a fix/feature within octopus.