Removing quotes from JSON variables


I am wondering if there is a way to remove the double quotes from Terraform JSON outputted variables.

For example, if I grab an output value from a previous terraform step:

#{Octopus.Action[Provision RDS].Output.TerraformValueOutputs[rds_address]}

It will return the value with double quotes and I need to insert a powershell script or step to clean it.


Hi Linden, thanks for reaching out.

As you have noticed the output value for TerraformValueOutputs is a serialized JSON value so there are a few ways to deal with this. As you have mentioned you could possibly deal with this using a PowerShell and converting from JSON using a script:

$OctopusParameters["Octopus.Action[Provision RDS].Output.TerraformValueOutputs[rds_address]"] | ConvertFrom-Json

// OR

$OctopusParameters["Octopus.Action[Provision RDS].Output.TerraformJsonOutputs[rds_address]"] | ConvertFrom-Json  | select -ExpandProperty value

You can also leverage Octostache’s ability to deal with JSON formatted variables as covered in our documentation here. This will, however, require you to use the TerraformJsonOutputs instead as there is no way to indicate to Octostache that the value from TerraformValueOutputs is a serialized JSON string value. You should be able to use the following to achieve what you are looking for:

#{Octopus.Action[Provision RDS].Output.TerraformJsonOutputs[rds_address].value}

Please let me know if that works for you.

Shaun Marx

Thanks very much Shaun, both of those methods work! (Would be handy to add this to the documentation on variables I think)

No problem Linden. I have added a task to make sure we get the documentation updated.

Let us know if there is anything else we can help with :slight_smile:

Shaun Marx