Skip to content

Commit

Permalink
Merge pull request #9698 from hashicorp/b-simple-var
Browse files Browse the repository at this point in the history
terraform: disallow simple variables ("foo")
  • Loading branch information
mitchellh authored Nov 8, 2016
2 parents 45b2bc1 + 3fd390b commit 261f0ee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
14 changes: 8 additions & 6 deletions terraform/interpolate.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,14 @@ func (i *Interpolater) valueSimpleVar(
n string,
v *config.SimpleVariable,
result map[string]ast.Variable) error {
// SimpleVars are never handled by Terraform's interpolator
result[n] = ast.Variable{
Value: config.UnknownVariableValue,
Type: ast.TypeString,
}
return nil
// This error message includes some information for people who
// relied on this for their template_file data sources. We should
// remove this at some point but there isn't any rush.
return fmt.Errorf(
"invalid variable syntax: %q. If this is part of inline `template` parameter\n" +
"then you must escape the interpolation with two dollar signs. For\n" +
"example: ${a} becomes $${a}." +
n)
}

func (i *Interpolater) valueUserVar(
Expand Down
6 changes: 6 additions & 0 deletions terraform/interpolate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ import (
"github.com/hashicorp/terraform/config"
)

func TestInterpolater_simpleVar(t *testing.T) {
i := &Interpolater{}
scope := &InterpolationScope{}
testInterpolateErr(t, i, scope, "simple")
}

func TestInterpolater_countIndex(t *testing.T) {
i := &Interpolater{}

Expand Down

0 comments on commit 261f0ee

Please sign in to comment.