For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/cloudformation-aws-connection-between-cloudfront-origin-not-encrypted.md.
A documentation index is available at /llms.txt.
CloudFront distributions must require or redirect viewers to HTTPS to prevent plaintext HTTP traffic that can expose sensitive data in transit and enable interception or downgrade attacks. In AWS::CloudFront::Distribution resources, set DistributionConfig.DefaultCacheBehavior.ViewerProtocolPolicy and each DistributionConfig.CacheBehaviors[].ViewerProtocolPolicy to https-only or redirect-to-https. Resources missing these properties or configured with allow-all (which permits HTTP) will be flagged as insecure.
#this code is a correct code for which the query should not find any resultAWSTemplateFormatVersion:"2010-09-09"Resources:cloudfrontdistribution:Type:AWS::CloudFront::DistributionProperties:DistributionConfig:CacheBehaviors:- LambdaFunctionAssociations:- EventType:viewer-requestLambdaFunctionARN:exampDefaultCacheBehavior:LambdaFunctionAssociations:- EventType:viewer-requestLambdaFunctionARN:exampIPV6Enabled:trueOrigins:- CustomOriginConfig:OriginKeepaliveTimeout:60OriginReadTimeout:30Tags:- Key:nameValue:example
#this is a problematic code where the query should report a result(s)AWSTemplateFormatVersion:"2010-09-09"Resources:cloudfrontdistribution_1:Type:AWS::CloudFront::DistributionProperties:DistributionConfig:CacheBehaviors:- LambdaFunctionAssociations:- EventType:viewer-requestLambdaFunctionARN:exampDefaultCacheBehavior:ViewerProtocolPolicy:allow-allLambdaFunctionAssociations:- EventType:viewer-requestLambdaFunctionARN:exampIPV6Enabled:trueOrigins:- CustomOriginConfig:OriginKeepaliveTimeout:60OriginReadTimeout:30Tags:- Key:nameValue:examplecloudfrontdistribution_2:Type:AWS::CloudFront::DistributionProperties:DistributionConfig:CacheBehaviors:ViewerProtocolPolicy:allow-allLambdaFunctionAssociations:- EventType:viewer-requestLambdaFunctionARN:exampDefaultCacheBehavior:LambdaFunctionAssociations:- EventType:viewer-requestLambdaFunctionARN:exampIPV6Enabled:trueOrigins:- CustomOriginConfig:OriginKeepaliveTimeout:60OriginReadTimeout:30Tags:- Key:nameValue:example