provider/aws: Fix flattened cloudfront lambda function associations to be a set, not a slice (#11984)
This commit is contained in:
parent
4d70f4539d
commit
c7546c7726
|
@ -443,10 +443,10 @@ func expandLambdaFunctionAssociation(lf map[string]interface{}) *cloudfront.Lamb
|
|||
return &lfa
|
||||
}
|
||||
|
||||
func flattenLambdaFunctionAssociations(lfa *cloudfront.LambdaFunctionAssociations) []interface{} {
|
||||
s := make([]interface{}, len(lfa.Items))
|
||||
for i, v := range lfa.Items {
|
||||
s[i] = flattenLambdaFunctionAssociation(v)
|
||||
func flattenLambdaFunctionAssociations(lfa *cloudfront.LambdaFunctionAssociations) *schema.Set {
|
||||
s := schema.NewSet(lambdaFunctionAssociationHash, []interface{}{})
|
||||
for _, v := range lfa.Items {
|
||||
s.Add(flattenLambdaFunctionAssociation(v))
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
|
|
@ -364,14 +364,8 @@ func TestCloudFrontStructure_flattenCacheBehavior(t *testing.T) {
|
|||
t.Fatalf("Expected out[target_origin_id] to be myS3Origin, got %v", out["target_origin_id"])
|
||||
}
|
||||
|
||||
// the flattened lambda function associations are a slice of maps,
|
||||
// where as the default cache behavior LFAs are a set. Here we double check
|
||||
// that and conver the slice to a set, and use Set's Equal() method to check
|
||||
// equality
|
||||
var outSet *schema.Set
|
||||
if outSlice, ok := out["lambda_function_association"].([]interface{}); ok {
|
||||
outSet = schema.NewSet(lambdaFunctionAssociationHash, outSlice)
|
||||
} else {
|
||||
var outSet, ok = out["lambda_function_association"].(*schema.Set)
|
||||
if !ok {
|
||||
t.Fatalf("out['lambda_function_association'] is not a slice as expected: %#v", out["lambda_function_association"])
|
||||
}
|
||||
|
||||
|
@ -496,7 +490,7 @@ func TestCloudFrontStructure_flattenlambdaFunctionAssociations(t *testing.T) {
|
|||
lfa := expandLambdaFunctionAssociations(in.List())
|
||||
out := flattenLambdaFunctionAssociations(lfa)
|
||||
|
||||
if reflect.DeepEqual(in.List(), out) != true {
|
||||
if reflect.DeepEqual(in.List(), out.List()) != true {
|
||||
t.Fatalf("Expected out to be %v, got %v", in, out)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue