Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource/cloudfront_distribution: re-introduce changes from #10013 to update active_trusted_signers attribute #14339

Merged
merged 10 commits into from
Jul 29, 2020
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"
anGie44 marked this conversation as resolved.
Show resolved Hide resolved
)

// 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