Search code examples
terraformoctopus-deploy

In Terraform what does the encapsulation "#{variableName}" syntax mean?


I am familiar with "${}" syntax, but can't find any reference to "#{}" in the Terraform docs, yet I see it in this example: Terraform v0.12 Multi-line String EOF shell-style "here doc" syntax not been interpreted as before with v0.11


Solution

  • It's not a Terraform thing, it's an Octopus Deploy thing instead.

    It's used for variable substitution so that you can define a variable in Octopus Deploy and have that injected into your Terraform before it runs the relevant Terraform commands.

    The Octopus docs for deploying with Terraform go into further detail and give the following example:

    provider "aws" { }
    
    resource "aws_instance" "example" {
      ami           = "#{AMI}"
      instance_type = "m3.medium"
      tags {
        Name = "My EC2 Instance"
      }
    }
    

    where #{AMI} would be replaced by the AMI id that Octopus has configured in the AMI variable.