From 91753409b93a7cfcecbe5008959bfe41d4d7edd8 Mon Sep 17 00:00:00 2001 From: clint shryock Date: Fri, 20 Jan 2017 11:25:30 -0600 Subject: [PATCH] fix issue where, depending on a creation of flattening, the lambda functions may be a set or an []interface{} --- ...nt_distribution_configuration_structure.go | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/builtin/providers/aws/cloudfront_distribution_configuration_structure.go b/builtin/providers/aws/cloudfront_distribution_configuration_structure.go index 64f9b55f66..ccac0d9c50 100644 --- a/builtin/providers/aws/cloudfront_distribution_configuration_structure.go +++ b/builtin/providers/aws/cloudfront_distribution_configuration_structure.go @@ -229,8 +229,14 @@ func defaultCacheBehaviorHash(v interface{}) int { } } if d, ok := m["lambda_function_association"]; ok { - s := d.(*schema.Set) - for _, lfa := range s.List() { + var associations []interface{} + switch d.(type) { + case *schema.Set: + associations = d.(*schema.Set).List() + default: + associations = d.([]interface{}) + } + for _, lfa := range associations { buf.WriteString(fmt.Sprintf("%d-", lambdaFunctionAssociationHash(lfa.(map[string]interface{})))) } } @@ -367,8 +373,14 @@ func cacheBehaviorHash(v interface{}) int { buf.WriteString(fmt.Sprintf("%s-", d)) } if d, ok := m["lambda_function_association"]; ok { - s := d.(*schema.Set) - for _, lfa := range s.List() { + var associations []interface{} + switch d.(type) { + case *schema.Set: + associations = d.(*schema.Set).List() + default: + associations = d.([]interface{}) + } + for _, lfa := range associations { buf.WriteString(fmt.Sprintf("%d-", lambdaFunctionAssociationHash(lfa.(map[string]interface{})))) } }