Update normalization

main
William Beuil 2021-02-24 15:13:17 +01:00
parent 9ad9c1f185
commit e515c8195f
No known key found for this signature in database
GPG Key ID: BED2072C5C2BF537
3 changed files with 180 additions and 2 deletions

View File

@ -63,7 +63,81 @@
}
],
"LoggingConfig": [],
"OrderedCacheBehavior": [],
"OrderedCacheBehavior": [
{
"AllowedMethods": [
"GET",
"HEAD",
"OPTIONS"
],
"CachedMethods": [
"GET",
"HEAD",
"OPTIONS"
],
"Compress": true,
"DefaultTtl": 86400,
"FieldLevelEncryptionId": null,
"MaxTtl": 31536000,
"MinTtl": 0,
"PathPattern": "/content/immutable/*",
"SmoothStreaming": false,
"TargetOriginId": "S3-foo-cloudfront",
"TrustedSigners": null,
"ViewerProtocolPolicy": "redirect-to-https",
"ForwardedValues": [
{
"Headers": [
"Origin"
],
"QueryString": false,
"QueryStringCacheKeys": null,
"Cookies": [
{
"Forward": "none",
"WhitelistedNames": null
}
]
}
],
"LambdaFunctionAssociation": null
},
{
"AllowedMethods": [
"GET",
"HEAD",
"OPTIONS"
],
"CachedMethods": [
"GET",
"HEAD"
],
"Compress": true,
"DefaultTtl": 3600,
"FieldLevelEncryptionId": null,
"MaxTtl": 86400,
"MinTtl": 0,
"PathPattern": "/content/*",
"SmoothStreaming": false,
"TargetOriginId": "S3-foo-cloudfront",
"TrustedSigners": null,
"ViewerProtocolPolicy": "redirect-to-https",
"ForwardedValues": [
{
"Headers": null,
"QueryString": false,
"QueryStringCacheKeys": null,
"Cookies": [
{
"Forward": "none",
"WhitelistedNames": null
}
]
}
],
"LambdaFunctionAssociation": null
}
],
"Origin": [
{
"DomainName": "foo-cloudfront.s3.eu-west-3.amazonaws.com",

View File

@ -65,7 +65,81 @@
"is_ipv6_enabled": false,
"last_modified_time": "2021-02-16 10:17:35.404 +0000 UTC",
"logging_config": [],
"ordered_cache_behavior": [],
"ordered_cache_behavior": [
{
"allowed_methods": [
"GET",
"HEAD",
"OPTIONS"
],
"cached_methods": [
"GET",
"HEAD",
"OPTIONS"
],
"compress": true,
"default_ttl": 86400,
"field_level_encryption_id": "",
"forwarded_values": [
{
"cookies": [
{
"forward": "none",
"whitelisted_names": null
}
],
"headers": [
"Origin"
],
"query_string": false,
"query_string_cache_keys": null
}
],
"lambda_function_association": [],
"max_ttl": 31536000,
"min_ttl": 0,
"path_pattern": "/content/immutable/*",
"smooth_streaming": false,
"target_origin_id": "S3-foo-cloudfront",
"trusted_signers": [],
"viewer_protocol_policy": "redirect-to-https"
},
{
"allowed_methods": [
"GET",
"HEAD",
"OPTIONS"
],
"cached_methods": [
"GET",
"HEAD"
],
"compress": true,
"default_ttl": 3600,
"field_level_encryption_id": "",
"forwarded_values": [
{
"cookies": [
{
"forward": "none",
"whitelisted_names": null
}
],
"headers": null,
"query_string": false,
"query_string_cache_keys": null
}
],
"lambda_function_association": [],
"max_ttl": 86400,
"min_ttl": 0,
"path_pattern": "/content/*",
"smooth_streaming": false,
"target_origin_id": "S3-foo-cloudfront",
"trusted_signers": null,
"viewer_protocol_policy": "redirect-to-https"
}
],
"origin": [
{
"custom_header": [],

View File

@ -52,4 +52,34 @@ func (r *AwsCloudfrontDistribution) normalizeNilPtr() {
}
}
}
if r.OrderedCacheBehavior != nil {
for i, b := range *r.OrderedCacheBehavior {
if b.LambdaFunctionAssociation != nil && len(*b.LambdaFunctionAssociation) == 0 {
(*r.OrderedCacheBehavior)[i].LambdaFunctionAssociation = nil
}
if b.ForwardedValues != nil && len(*b.ForwardedValues) == 0 {
(*r.OrderedCacheBehavior)[i].ForwardedValues = nil
}
if b.TrustedSigners != nil && len(*b.TrustedSigners) == 0 {
(*r.OrderedCacheBehavior)[i].TrustedSigners = nil
}
if b.ForwardedValues != nil {
for j, f := range *b.ForwardedValues {
if f.Headers != nil && len(*f.Headers) == 0 {
(*(*r.OrderedCacheBehavior)[i].ForwardedValues)[j].Headers = nil
}
if f.Cookies != nil {
for k, c := range *f.Cookies {
if c.WhitelistedNames != nil && len(*c.WhitelistedNames) == 0 {
(*(*(*r.OrderedCacheBehavior)[i].ForwardedValues)[j].Cookies)[k].WhitelistedNames = nil
}
}
}
}
}
if b.FieldLevelEncryptionId != nil && *b.FieldLevelEncryptionId == "" {
(*r.OrderedCacheBehavior)[i].FieldLevelEncryptionId = nil
}
}
}
}