Skip to content

Commit f0ed5e4

Browse files
authored
fix(misconf): do not set default value for default_cache_behavior (#7234)
Signed-off-by: nikpivkin <[email protected]>
1 parent a817fae commit f0ed5e4

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pkg/iac/adapters/terraform/aws/cloudfront/adapt.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func adaptDistribution(resource *terraform.Block) cloudfront.Distribution {
3333
},
3434
DefaultCacheBehaviour: cloudfront.CacheBehaviour{
3535
Metadata: resource.GetMetadata(),
36-
ViewerProtocolPolicy: types.String("allow-all", resource.GetMetadata()),
36+
ViewerProtocolPolicy: types.StringDefault("", resource.GetMetadata()),
3737
},
3838
OrdererCacheBehaviours: nil,
3939
ViewerCertificate: cloudfront.ViewerCertificate{
@@ -53,13 +53,13 @@ func adaptDistribution(resource *terraform.Block) cloudfront.Distribution {
5353
if defaultCacheBlock := resource.GetBlock("default_cache_behavior"); defaultCacheBlock.IsNotNil() {
5454
distribution.DefaultCacheBehaviour.Metadata = defaultCacheBlock.GetMetadata()
5555
viewerProtocolPolicyAttr := defaultCacheBlock.GetAttribute("viewer_protocol_policy")
56-
distribution.DefaultCacheBehaviour.ViewerProtocolPolicy = viewerProtocolPolicyAttr.AsStringValueOrDefault("allow-all", defaultCacheBlock)
56+
distribution.DefaultCacheBehaviour.ViewerProtocolPolicy = viewerProtocolPolicyAttr.AsStringValueOrDefault("", defaultCacheBlock)
5757
}
5858

5959
orderedCacheBlocks := resource.GetBlocks("ordered_cache_behavior")
6060
for _, orderedCacheBlock := range orderedCacheBlocks {
6161
viewerProtocolPolicyAttr := orderedCacheBlock.GetAttribute("viewer_protocol_policy")
62-
viewerProtocolPolicyVal := viewerProtocolPolicyAttr.AsStringValueOrDefault("allow-all", orderedCacheBlock)
62+
viewerProtocolPolicyVal := viewerProtocolPolicyAttr.AsStringValueOrDefault("", orderedCacheBlock)
6363
distribution.OrdererCacheBehaviours = append(distribution.OrdererCacheBehaviours, cloudfront.CacheBehaviour{
6464
Metadata: orderedCacheBlock.GetMetadata(),
6565
ViewerProtocolPolicy: viewerProtocolPolicyVal,

pkg/iac/adapters/terraform/aws/cloudfront/adapt_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func Test_adaptDistribution(t *testing.T) {
8383
},
8484
DefaultCacheBehaviour: cloudfront.CacheBehaviour{
8585
Metadata: iacTypes.NewTestMetadata(),
86-
ViewerProtocolPolicy: iacTypes.String("allow-all", iacTypes.NewTestMetadata()),
86+
ViewerProtocolPolicy: iacTypes.String("", iacTypes.NewTestMetadata()),
8787
},
8888

8989
ViewerCertificate: cloudfront.ViewerCertificate{

0 commit comments

Comments
 (0)