From 4bcf6cf6b2dd2620ef2a397909c45e1f22dfb31b Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 17 Feb 2015 13:32:45 -0800 Subject: [PATCH] config: bare splat variables should not be allowed in provisioners [GH-636] --- config/config.go | 7 +++++++ config/config_test.go | 7 +++++++ .../validate-var-multi-non-slice-provisioner/main.tf | 9 +++++++++ 3 files changed, 23 insertions(+) create mode 100644 config/test-fixtures/validate-var-multi-non-slice-provisioner/main.tf diff --git a/config/config.go b/config/config.go index 7c22ee6bf..0a538449e 100644 --- a/config/config.go +++ b/config/config.go @@ -465,6 +465,13 @@ func (c *Config) rawConfigs() map[string]*RawConfig { source := fmt.Sprintf("resource '%s'", rc.Id()) result[source+" count"] = rc.RawCount result[source+" config"] = rc.RawConfig + + for i, p := range rc.Provisioners { + subsource := fmt.Sprintf( + "%s provisioner %s (#%d)", + source, p.Type, i+1) + result[subsource] = p.RawConfig + } } for _, o := range c.Outputs { diff --git a/config/config_test.go b/config/config_test.go index 22cb75d0e..5586f60f1 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -249,6 +249,13 @@ func TestConfigValidate_varMultiNonSlice(t *testing.T) { } } +func TestConfigValidate_varMultiNonSliceProvisioner(t *testing.T) { + c := testConfig(t, "validate-var-multi-non-slice-provisioner") + if err := c.Validate(); err == nil { + t.Fatal("should not be valid") + } +} + func TestConfigValidate_varMultiFunctionCall(t *testing.T) { c := testConfig(t, "validate-var-multi-func") if err := c.Validate(); err != nil { diff --git a/config/test-fixtures/validate-var-multi-non-slice-provisioner/main.tf b/config/test-fixtures/validate-var-multi-non-slice-provisioner/main.tf new file mode 100644 index 000000000..c790b7c84 --- /dev/null +++ b/config/test-fixtures/validate-var-multi-non-slice-provisioner/main.tf @@ -0,0 +1,9 @@ +resource "aws_instance" "foo" { + count = 3 +} + +resource "aws_instance" "bar" { + provisioner "local-exec" { + foo = "${aws_instance.foo.*.id}" + } +}