diff --git a/CHANGELOG.md b/CHANGELOG.md index 407c77cb10..c375c92589 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ BUG FIXES: * core: The `file()` function can load files in sub-directories. [GH-213] * core: Fix issue where some JSON structures didn't map properly into Terraform structures. [GH-177] + * core: Resources with only `file()` calls will interpolate. [GH-159] * providers/aws: Fix issues around failing to read EIPs. [GH-122] * providers/aws: Autoscaling groups now register and export load balancers. [GH-207] diff --git a/config/raw_config.go b/config/raw_config.go index c97b29c527..d10a16010e 100644 --- a/config/raw_config.go +++ b/config/raw_config.go @@ -25,6 +25,7 @@ const UnknownVariableValue = "74D93920-ED26-11E3-AC10-0800200C9A66" // information from deep within the structure. type RawConfig struct { Raw map[string]interface{} + Interpolations []Interpolation Variables map[string]InterpolatedVariable config map[string]interface{} @@ -87,9 +88,12 @@ func (r *RawConfig) Interpolate(vs map[string]string) error { func (r *RawConfig) init() error { r.config = r.Raw + r.Interpolations = nil r.Variables = nil fn := func(i Interpolation) (string, error) { + r.Interpolations = append(r.Interpolations, i) + for k, v := range i.Variables() { if r.Variables == nil { r.Variables = make(map[string]InterpolatedVariable) diff --git a/config/raw_config_test.go b/config/raw_config_test.go index eefec193f5..9746f200e2 100644 --- a/config/raw_config_test.go +++ b/config/raw_config_test.go @@ -9,6 +9,7 @@ import ( func TestNewRawConfig(t *testing.T) { raw := map[string]interface{}{ "foo": "${var.bar}", + "bar": `${file("boom.txt")}`, } rc, err := NewRawConfig(raw) @@ -16,6 +17,9 @@ func TestNewRawConfig(t *testing.T) { t.Fatalf("err: %s", err) } + if len(rc.Interpolations) != 2 { + t.Fatalf("bad: %#v", rc.Interpolations) + } if len(rc.Variables) != 1 { t.Fatalf("bad: %#v", rc.Variables) } diff --git a/terraform/context.go b/terraform/context.go index cb598da654..568c02875d 100644 --- a/terraform/context.go +++ b/terraform/context.go @@ -305,11 +305,6 @@ func (c *Context) computeVars(raw *config.RawConfig) error { return nil } - // If there are on variables, then we're done - if len(raw.Variables) == 0 { - return nil - } - // Start building up the variables. First, defaults vs := make(map[string]string) for k, v := range c.defaultVars {