diff --git a/builtin/providers/aws/structure.go b/builtin/providers/aws/structure.go index 18a48b6de..a1533056c 100644 --- a/builtin/providers/aws/structure.go +++ b/builtin/providers/aws/structure.go @@ -1,6 +1,8 @@ package aws import ( + "strings" + "github.com/mitchellh/goamz/autoscaling" "github.com/mitchellh/goamz/ec2" "github.com/mitchellh/goamz/elb" @@ -134,6 +136,14 @@ func flattenInstances(list []elb.Instance) []string { // Takes the result of flatmap.Expand for an array of strings // and returns a []string func expandStringList(configured []interface{}) []string { + // here we special case the * expanded lists. For example: + // + // instances = ["${aws_instance.foo.*.id}"] + // + if len(configured) == 1 && strings.Contains(configured[0].(string), ",") { + return strings.Split(configured[0].(string), ",") + } + vs := make([]string, 0, len(configured)) for _, v := range configured { vs = append(vs, v.(string)) diff --git a/builtin/providers/aws/structure_test.go b/builtin/providers/aws/structure_test.go index 2466af96d..c1c2e7371 100644 --- a/builtin/providers/aws/structure_test.go +++ b/builtin/providers/aws/structure_test.go @@ -90,3 +90,19 @@ func Test_expandStringList(t *testing.T) { } } + +func Test_expandStringListWildcard(t *testing.T) { + stringList := expandStringList([]interface{}{"us-east-1a,us-east-1b"}) + expected := []string{ + "us-east-1a", + "us-east-1b", + } + + if !reflect.DeepEqual(stringList, expected) { + t.Fatalf( + "Got:\n\n%#v\n\nExpected:\n\n%#v\n", + stringList, + expected) + } + +}