Skip to content

Commit

Permalink
Merge pull request #14339 from terraform-providers/td-cloudfront-dist…
Browse files Browse the repository at this point in the history
…ribution-flatmap

resource/cloudfront_distribution: re-introduce changes from #10013 to update active_trusted_signers attribute
  • Loading branch information
anGie44 authored Jul 29, 2020
2 parents fce4cc0 + d7099d2 commit b168604
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 393 deletions.
39 changes: 24 additions & 15 deletions aws/cloudfront_distribution_configuration_structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/hashcode"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/flatmap"
)

// cloudFrontRoute53ZoneID defines the route 53 zone ID for CloudFront. This
Expand Down Expand Up @@ -1097,20 +1096,30 @@ func flattenViewerCertificate(vc *cloudfront.ViewerCertificate) []interface{} {
return []interface{}{m}
}

// Convert *cloudfront.ActiveTrustedSigners to a flatmap.Map type, which ensures
// it can probably be inserted into the schema.TypeMap type used by the
// active_trusted_signers attribute.
func flattenActiveTrustedSigners(ats *cloudfront.ActiveTrustedSigners) flatmap.Map {
m := make(map[string]interface{})
s := []interface{}{}
m["enabled"] = *ats.Enabled
func flattenCloudfrontActiveTrustedSigners(ats *cloudfront.ActiveTrustedSigners) []interface{} {
if ats == nil {
return []interface{}{}
}

m := map[string]interface{}{
"enabled": aws.BoolValue(ats.Enabled),
"items": flattenCloudfrontSigners(ats.Items),
}

return []interface{}{m}
}

for _, v := range ats.Items {
signer := make(map[string]interface{})
signer["aws_account_number"] = *v.AwsAccountNumber
signer["key_pair_ids"] = aws.StringValueSlice(v.KeyPairIds.Items)
s = append(s, signer)
func flattenCloudfrontSigners(signers []*cloudfront.Signer) []interface{} {
result := make([]interface{}, 0, len(signers))

for _, signer := range signers {
m := map[string]interface{}{
"aws_account_number": aws.StringValue(signer.AwsAccountNumber),
"key_pair_ids": aws.StringValueSlice(signer.KeyPairIds.Items),
}

result = append(result, m)
}
m["items"] = s
return flatmap.Flatten(m)

return result
}
3 changes: 0 additions & 3 deletions aws/internal/flatmap/README.md

This file was deleted.

71 changes: 0 additions & 71 deletions aws/internal/flatmap/flatten.go

This file was deleted.

88 changes: 0 additions & 88 deletions aws/internal/flatmap/flatten_test.go

This file was deleted.

82 changes: 0 additions & 82 deletions aws/internal/flatmap/map.go

This file was deleted.

Loading

0 comments on commit b168604

Please sign in to comment.